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 and desktop #10598

Closed
4 tasks done
DonJayamanne opened this issue Jun 27, 2022 · 2 comments
Closed
4 tasks done

Test IPyWidgets in vscode.dev and desktop #10598

DonJayamanne opened this issue Jun 27, 2022 · 2 comments

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Jun 27, 2022

Testing the jupyter extension loading ipywidgets

Refs: #10434

Complexity: 5

Authors: @DonJayamanne

Create Issue


Requirements

  • Install prerelease jupyter extension into VS Code (desktop or http://insiders.vscode.dev)
  • Have a python environment that you can run jupyter from. (https://jupyter.org/install)
  • Be familiar with jupyter notebooks
  • Use Python 3.6 or later (please ensure you aren't using Python 2, use python --version to check the version)
  • Have ipywidgets installed into your python environment using the command python -m pip install ipywidgets

Pre test steps (vscode.web)

  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. If on VS Code web, then pick the 'Python 3' kernel on web else pick the local Python environment you setup in Pre test steps
  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
  • ipyleaflet
  • k3d
  • bqplot
  1. Go back and try the widgets provided in the samples below (optionally test the widgets found here https://jupyter.org/widgets)
Sample code (click to expand)
# Sample1
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)
# Sample2
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()
# Sample3
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.
  2. Pick yes
  3. Test again without the CDN option
    You might want to change this by going into your settings.json and update as follows (empty array setting):
  "jupyter.widgetScriptSources": [ ],
  1. Verify you get some sort of output in the cell from running the widget.

Note: Please test with and without CDN. When testing without CDN you could either wait for the prompt to use CDN or go into the settings.json file and add the setting "jupyter.widgetScriptSources": [ ], and re-run the above tests.

@github-actions github-actions bot added the triage-needed Issue needs to be triaged label Jun 27, 2022
@rzhao271 rzhao271 added this to the June 2022 milestone Jun 28, 2022
@rzhao271 rzhao271 removed the triage-needed Issue needs to be triaged label Jun 28, 2022
@aeschli
Copy link

aeschli commented Jun 28, 2022

Cool stuff!

Tested on Linux

@rebornix
Copy link
Member

Tested insiders.vscode.dev on Edge. The setup steps are detailed and helpful, and it works as charm, great work!

@rebornix rebornix removed their assignment Jun 28, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants