Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test IPyWidgets in vscode.dev #10165

Closed
2 tasks done
rchiodo opened this issue May 27, 2022 · 2 comments
Closed
2 tasks done

Test IPyWidgets in vscode.dev #10165

rchiodo opened this issue May 27, 2022 · 2 comments
Labels
testplan-item triage-needed Issue needs to be triaged
Milestone

Comments

@rchiodo
Copy link
Contributor

rchiodo commented May 27, 2022

Testing the jupyter web extension loading ipywidgets

Refs: #9984

Complexity: 5

Authors: @rchiodo

Create Issue


Requirements

Pre test steps

  1. Go to a command prompt
  2. Activate the python environment with jupyter in it
  3. Run jupyter with the following command line : jupyter notebook --no-browser --NotebookApp.allow_origin=*
  4. Note the URL it generates for connecting
  5. Start insiders.vscode.dev
  6. Make sure Jupyter prerelease extension is installed
  7. Bring up command palette
  8. Pick 'Jupyter: Specify jupyter server for connections'
  9. Pick 'Existing'
  10. Enter the URL from step 4

Test standard widgets

  1. Open a new notebook
  2. Pick the 'Python 3' kernel
  3. Try some of the standard widgets from the blog post. Here's an example:
import ipywidgets as widgets
widgets.IntSlider()
  1. Make sure the widget can be interacted with (the example above should generate something like so:)
    image
  2. Try other standard widgets

Test more complex widgets

  1. Create another notebook
  2. Go to a new command prompt
  3. Activate your python environment that jupyter is using
  4. Conda/Pip install the following:
  • numpy
  • pandas
  • ipyleaflets
  • k3d
  • bqplot
  1. Go back to insiders.vscode.dev and add these cells to the notebook
from ipyleaflet import Map, Marker

center = (52.204793, 360.121558)

m = Map(center=center, zoom=15)

marker = Marker(location=center, draggable=True)
m.add_layer(marker);

display(m)
import k3d
import numpy as np
from numpy import sin,cos,pi
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
import time
import math

plot = k3d.plot()

plot.camera_auto_fit = False

T = 1.618033988749895
r = 4.77
zmin,zmax = -r,r
xmin,xmax = -r,r
ymin,ymax = -r,r
Nx,Ny,Nz = 77,77,77

x = np.linspace(xmin,xmax,Nx)
y = np.linspace(ymin,ymax,Ny)
z = np.linspace(zmin,zmax,Nz)
x,y,z = np.meshgrid(x,y,z,indexing='ij')
p = 2 - (cos(x + T*y) + cos(x - T*y) + cos(y + T*z) + cos(y - T*z) + cos(z - T*x) + cos(z + T*x))
iso = k3d.marching_cubes(p.astype(np.float32),xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax, zmin=zmin, zmax=zmax, level=0.0)
plot += iso

plot.display()
import numpy as np
from bqplot import pyplot as plt

# And creating some random data
size = 100
np.random.seed(0)
x_data = np.arange(size)
y_data = np.cumsum(np.random.randn(size)  * 100.0)
plt.figure(title='My First Plot')
plt.plot(x_data, y_data)
plt.show()
  1. You should be asked to allow usage of a CND for widgets. Pick yes.
  2. Verify you get some sort of output in the cell from running the widget.
@github-actions github-actions bot added the triage-needed Issue needs to be triaged label May 27, 2022
@ghost ghost assigned weinand and karrtikr May 31, 2022
@weinand
Copy link

weinand commented May 31, 2022

@rchiodo The "Pre test steps" from above lack the installation of the ipywidgets:

pip install ipywidgets

I tried some of the "ipywidgets" and they seem to work fine.

For the "Test more complex widgets" section I only see a widget in the third cell:
CleanShot 2022-05-31 at 16 06 02@2x

The first cell shows no widget and I see these errors in the devtools console:
CleanShot 2022-05-31 at 16 10 02@2x

The second cell runs for a long time but doesn't show a widget.
The devtools console shows this:
CleanShot 2022-05-31 at 16 11 48@2x

I'm on macOS 12.4 and I'm using python 3.10.0 and pip 22.1.2 via pyenv.

@weinand weinand removed their assignment May 31, 2022
@weinand
Copy link

weinand commented May 31, 2022

@rchiodo after running jupyter labextension install jupyter-leaflet and restarting the kernel the two failing samples started to work:

CleanShot 2022-05-31 at 16 33 13@2x

CleanShot 2022-05-31 at 16 34 41@2x

@weinand weinand added this to the May 2022 milestone May 31, 2022
@karrtikr karrtikr removed their assignment Jun 1, 2022
@karrtikr karrtikr closed this as completed Jun 1, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
testplan-item triage-needed Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants