glue-viz / bqplot-image-gl

Jupyter widget for displaying images with a focus on astronomy
MIT License
19 stars 13 forks source link

Widget not working correctly with voila #20

Closed astrofrog closed 4 years ago

astrofrog commented 4 years ago

I set up a minimal Python 3.8 environment with:

$ python -m venv ~/python/minimal
$ source ~/python/minimal/bin/activate
$ pip install bqplot-image-gl bqplot numpy voila
$ pip freeze
async-generator==1.10
attrs==19.3.0
backcall==0.1.0
bleach==3.1.3
bqplot==0.12.6
bqplot-image-gl==0.3.0
decorator==4.4.2
defusedxml==0.6.0
entrypoints==0.3
ipykernel==5.2.0
ipython==7.13.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.16.0
Jinja2==2.11.1
jsonschema==3.2.0
jupyter-client==6.1.1
jupyter-core==4.6.3
jupyter-server==0.1.1
jupyterlab-pygments==0.1.0
MarkupSafe==1.1.1
mistune==0.8.4
nbconvert==5.6.1
nbformat==5.0.4
notebook==6.0.3
numpy==1.18.2
pandas==1.0.3
pandocfilters==1.4.2
parso==0.6.2
pexpect==4.8.0
pickleshare==0.7.5
pkg-resources==0.0.0
prometheus-client==0.7.1
prompt-toolkit==3.0.4
ptyprocess==0.6.0
Pygments==2.6.1
pyrsistent==0.16.0
python-dateutil==2.8.1
pytz==2019.3
pyzmq==19.0.0
Send2Trash==1.5.0
six==1.14.0
terminado==0.8.3
testpath==0.4.4
tornado==6.0.4
traitlets==4.3.3
traittypes==0.2.1
voila==0.1.21
wcwidth==0.1.9
webencodings==0.5.1
widgetsnbextension==3.5.1

If I then execute the following notebook:

https://gist.github.com/astrofrog/45eab0b3b978b7fd4c35a7520e97220a

using jupyter notebook basic.ipynb, everything works fine. However, if I do voila basic.ipynb the figure doesn't appear and I get the following errors in the js console:

Starting WebSocket: ws://localhost:8867/api/kernels/36660288-f960-4f42-a56f-5cea42f3b48a default.js:56
Kernel: connected (36660288-f960-4f42-a56f-5cea42f3b48a) default.js:1452
Loading failed for the <script> with source “http://localhost:8867/voila/bqplot.js”. localhost:8867:1:1
Falling back to https://unpkg.com/ for bqplot@^0.5.6 6 loader.js:78
Loading failed for the <script> with source “http://localhost:8867/voila/bqplot-image-gl.js”. localhost:8867:1:1
Falling back to https://unpkg.com/ for bqplot@^0.5.6 2 loader.js:78
Falling back to https://unpkg.com/ for bqplot-image-gl@^0.3.0 loader.js:78
Falling back to https://unpkg.com/ for bqplot-image-gl@^0.2.0 loader.js:78
Could not instantiate widget manager-base.js:273
uncaught exception: Class BrushEllipseSelectorModel not found in module bqplot-image-gl@^0.2.0
maartenbreddels commented 4 years ago

Falling back to https://unpkg.com/ for bqplot-image-gl@^0.3.0 loader.js:78 Falling back to https://unpkg.com/ for bqplot-image-gl@^0.2.0 loader.js:78

From this, I guess we have not updated versions in all the components. For instance in https://github.com/glue-viz/bqplot-image-gl/blob/2fd62baa6d8713279a58a7863e104a8f1390352c/js/lib/BrushEllipseSelectorModel.js#L6

We shouldn't hard code the version number, but take it from package.json (my fault btw)

astrofrog commented 4 years ago

Still seems to be an issue...

maartenbreddels commented 4 years ago

The problem is our embed.js didn't export all modules (fix is coming)

But I wanted to be able to test this locally, for the archive, to test a js embed module before releasing you can do (from the root of the project):

$ mkdir examples/voila
$ ln js/dist/index.js examples/voila/bqplot-image-gl.js
$ voila examples/brush-ellipse.ipynb --autoreload=True --no-browser --VoilaConfiguration.file_whitelist="['.*\.(png|jpg|gif|svg|js)']"