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

Widgets not rendering when using jupyterlite-pyodide-kernel #86

Closed
jsignell opened this issue Aug 1, 2023 · 10 comments
Closed

Widgets not rendering when using jupyterlite-pyodide-kernel #86

jsignell opened this issue Aug 1, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@jsignell
Copy link

jsignell commented Aug 1, 2023

Let me just say I am not at all sure that this is the right repo to raise this in. But ipywidgets work fine in jupyterlite, so I'm not sure where else to put it.

Description

ipywidgets are not rendering when used with jupyterlite-pyodide-kernel

image

Reproduce

  1. Go to https://jsignell.github.io/voici/voici/render/demo.html?
  2. Slider does not render

From the console log it looks like @jupyter-widgets/base and @jupyter-widgets/controls are missing.

Context

The notebook and requirements are in the following repo: https://github.com/jsignell/voici

@jsignell jsignell added the bug Something isn't working label Aug 1, 2023
@martinRenou
Copy link
Member

The way it fails is surprising to me. I suspect one of the widgets libraries you are installing is requesting a wrong version of ipywidgets (putting my bet on ipyevents, could you try removing it from your requirements?).

@jsignell
Copy link
Author

jsignell commented Aug 2, 2023

Hmm I tried creating a more minimal environment and removing the pins:

jupyterlite-core
jupyterlab~=3.5.1
jupyterlite-pyodide-kernel
jupyterlab-geojson
ipywidgets==8.0
ipyleaflet
bqplot
voici

Still getting the same issue. I did notice locally that voici seems to be looking for the pyodide kernel at a nested url. So it is looking for:

/voici/render/extensions/@jupyterlite/pyodide-kernel-extension/static/pypi/all.json?sha256=c34f9fdb521c609edea81ebbb122612d7d7c9e2ad738d791fa77622d0f03be12

rather than:

/extensions/@jupyterlite/pyodide-kernel-extension/static/pypi/all.json?sha256=c34f9fdb521c609edea81ebbb122612d7d7c9e2ad738d791fa77622d0f03be12

but I'm pretty sure that is unrelated

I also tried running regular voila and I was getting the same errors there. If I bump down the voila version to 0.4.3 the widgets are ok in voila, but voici doesn't work at all.

Here is my env dump:

conda list -n voici
# packages in environment at /home/jsignell/conda/envs/voici:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
aiofiles                  22.1.0                   pypi_0    pypi
aiosqlite                 0.19.0                   pypi_0    pypi
anyio                     3.7.1                    pypi_0    pypi
argon2-cffi               21.3.0                   pypi_0    pypi
argon2-cffi-bindings      21.2.0                   pypi_0    pypi
arrow                     1.2.3                    pypi_0    pypi
asttokens                 2.2.1                    pypi_0    pypi
async-lru                 2.0.4                    pypi_0    pypi
attrs                     23.1.0                   pypi_0    pypi
babel                     2.12.1                   pypi_0    pypi
backcall                  0.2.0                    pypi_0    pypi
beautifulsoup4            4.12.2                   pypi_0    pypi
bleach                    6.0.0                    pypi_0    pypi
bqplot                    0.12.40                  pypi_0    pypi
branca                    0.6.0                    pypi_0    pypi
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2023.7.22            hbcca054_0    conda-forge
certifi                   2023.7.22                pypi_0    pypi
cffi                      1.15.1                   pypi_0    pypi
charset-normalizer        3.2.0                    pypi_0    pypi
cloudpickle               2.2.1                    pypi_0    pypi
comm                      0.1.4                    pypi_0    pypi
debugpy                   1.6.7                    pypi_0    pypi
decorator                 5.1.1                    pypi_0    pypi
defusedxml                0.7.1                    pypi_0    pypi
doit                      0.36.0                   pypi_0    pypi
entrypoints               0.4                      pypi_0    pypi
exceptiongroup            1.1.2                    pypi_0    pypi
executing                 1.2.0                    pypi_0    pypi
fastjsonschema            2.18.0                   pypi_0    pypi
fqdn                      1.5.1                    pypi_0    pypi
idna                      3.4                      pypi_0    pypi
importlib-metadata        6.8.0                    pypi_0    pypi
ipykernel                 6.25.0                   pypi_0    pypi
ipyleaflet                0.17.3                   pypi_0    pypi
ipython                   8.14.0                   pypi_0    pypi
ipython-genutils          0.2.0                    pypi_0    pypi
ipywidgets                8.0.0                    pypi_0    pypi
isoduration               20.11.0                  pypi_0    pypi
jedi                      0.19.0                   pypi_0    pypi
jinja2                    3.1.2                    pypi_0    pypi
json5                     0.9.14                   pypi_0    pypi
jsonpointer               2.4                      pypi_0    pypi
jsonschema                4.18.4                   pypi_0    pypi
jsonschema-specifications 2023.7.1                 pypi_0    pypi
jupyter-client            7.4.9                    pypi_0    pypi
jupyter-core              5.3.1                    pypi_0    pypi
jupyter-events            0.7.0                    pypi_0    pypi
jupyter-lsp               2.2.0                    pypi_0    pypi
jupyter-server            2.7.0                    pypi_0    pypi
jupyter-server-fileid     0.9.0                    pypi_0    pypi
jupyter-server-terminals  0.4.4                    pypi_0    pypi
jupyter-server-ydoc       0.8.0                    pypi_0    pypi
jupyter-ydoc              0.2.5                    pypi_0    pypi
jupyterlab                3.5.3                    pypi_0    pypi
jupyterlab-geojson        3.4.0                    pypi_0    pypi
jupyterlab-pygments       0.2.2                    pypi_0    pypi
jupyterlab-server         2.24.0                   pypi_0    pypi
jupyterlab-widgets        3.0.8                    pypi_0    pypi
jupyterlite-core          0.1.1                    pypi_0    pypi
jupyterlite-pyodide-kernel 0.0.9                    pypi_0    pypi
ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 13.1.0               he5830b7_0    conda-forge
libgomp                   13.1.0               he5830b7_0    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libsqlite                 3.42.0               h2797004_0    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
markupsafe                2.1.3                    pypi_0    pypi
matplotlib-inline         0.1.6                    pypi_0    pypi
mistune                   3.0.1                    pypi_0    pypi
nbclassic                 0.5.6                    pypi_0    pypi
nbclient                  0.7.4                    pypi_0    pypi
nbconvert                 7.7.3                    pypi_0    pypi
nbformat                  5.9.2                    pypi_0    pypi
ncurses                   6.4                  hcb278e6_0    conda-forge
nest-asyncio              1.5.7                    pypi_0    pypi
notebook                  6.5.5                    pypi_0    pypi
notebook-shim             0.2.3                    pypi_0    pypi
numpy                     1.25.2                   pypi_0    pypi
openssl                   3.1.2                hd590300_0    conda-forge
overrides                 7.3.1                    pypi_0    pypi
packaging                 23.1                     pypi_0    pypi
pandas                    2.0.3                    pypi_0    pypi
pandocfilters             1.5.0                    pypi_0    pypi
parso                     0.8.3                    pypi_0    pypi
pexpect                   4.8.0                    pypi_0    pypi
pickleshare               0.7.5                    pypi_0    pypi
pip                       23.2.1             pyhd8ed1ab_0    conda-forge
pkginfo                   1.9.6                    pypi_0    pypi
platformdirs              3.10.0                   pypi_0    pypi
prometheus-client         0.17.1                   pypi_0    pypi
prompt-toolkit            3.0.39                   pypi_0    pypi
psutil                    5.9.5                    pypi_0    pypi
ptyprocess                0.7.0                    pypi_0    pypi
pure-eval                 0.2.2                    pypi_0    pypi
pycparser                 2.21                     pypi_0    pypi
pygments                  2.15.1                   pypi_0    pypi
python                    3.10.12         hd12c33a_0_cpython    conda-forge
python-dateutil           2.8.2                    pypi_0    pypi
python-json-logger        2.0.7                    pypi_0    pypi
pytz                      2023.3                   pypi_0    pypi
pyyaml                    6.0.1                    pypi_0    pypi
pyzmq                     24.0.1                   pypi_0    pypi
readline                  8.2                  h8228510_1    conda-forge
referencing               0.30.0                   pypi_0    pypi
requests                  2.31.0                   pypi_0    pypi
rfc3339-validator         0.1.4                    pypi_0    pypi
rfc3986-validator         0.1.1                    pypi_0    pypi
rpds-py                   0.9.2                    pypi_0    pypi
send2trash                1.8.2                    pypi_0    pypi
setuptools                68.0.0             pyhd8ed1ab_0    conda-forge
six                       1.16.0                   pypi_0    pypi
sniffio                   1.3.0                    pypi_0    pypi
soupsieve                 2.4.1                    pypi_0    pypi
stack-data                0.6.2                    pypi_0    pypi
terminado                 0.17.1                   pypi_0    pypi
tinycss2                  1.2.1                    pypi_0    pypi
tk                        8.6.12               h27826a3_0    conda-forge
tomli                     2.0.1                    pypi_0    pypi
tornado                   6.3.2                    pypi_0    pypi
traitlets                 5.9.0                    pypi_0    pypi
traittypes                0.2.1                    pypi_0    pypi
typing-extensions         4.7.1                    pypi_0    pypi
tzdata                    2023.3                   pypi_0    pypi
uri-template              1.3.0                    pypi_0    pypi
urllib3                   2.0.4                    pypi_0    pypi
voici                     0.4.5                    pypi_0    pypi
voila                     0.5.0a4                  pypi_0    pypi
wcwidth                   0.2.6                    pypi_0    pypi
webcolors                 1.13                     pypi_0    pypi
webencodings              0.5.1                    pypi_0    pypi
websocket-client          1.6.1                    pypi_0    pypi
websockets                11.0.3                   pypi_0    pypi
wheel                     0.41.0             pyhd8ed1ab_0    conda-forge
widgetsnbextension        4.0.8                    pypi_0    pypi
xyzservices               2023.7.0                 pypi_0    pypi
xz                        5.2.6                h166bdaf_0    conda-forge
y-py                      0.6.0                    pypi_0    pypi
ypy-websocket             0.8.4                    pypi_0    pypi
zipp                      3.16.2                   pypi_0    pypi

@martinRenou
Copy link
Member

Indeed voici needs an alpha release of Voila (it's still very much work in progress).

I wonder if jupyterlite-pyodide-kernel isn't looking in some weird places for the lab extensions, leading to mismatching versions.

Would you get more luck using jupyterlite-xeus-python instead?

@jsignell
Copy link
Author

jsignell commented Aug 2, 2023

I wonder if jupyterlite-pyodide-kernel isn't looking in some weird places for the lab extensions, leading to mismatching versions.

Yeah that is what I originally thought as well, but it doesn't seem to explain why using regular voila=0.5.0a4 in regular jupyterlab with ipykernel also has the same error.

Would you get more luck using jupyterlite-xeus-python instead?

Yes that's where I started. But I had just originally wrote the notebook in jupyterlite with a pyodide kernel and when switching to xeus-python I ran into a few issues:

  1. lack of geopandas (Package geopandas emscripten-forge/recipes#315)
  2. I was using from js import fetch which does not seem to exist in xeus-python. This can obviously be easily resolved by using something else to fetch, but it made me a little uneasy that it might be more annoying than I had anticipated to swap back and forth between different kernels.

@martinRenou
Copy link
Member

I also tried running regular voila and I was getting the same errors there

I'll have to investigate this. This should not be the case.

@jsignell
Copy link
Author

jsignell commented Aug 2, 2023

Thank you! Let me know if you need any more information. Just to reiterate the widget rendering was failing with voila=0.5.0a4, but succeeding with voila=0.4.3

@martinRenou
Copy link
Member

I can reproduce. It looks like I have very bad memory because I did fix it in the specific Voici + jupyterlite-xeus-python case a couple of weeks ago https://github.com/voila-dashboards/voici/blob/main/voici/addon.py#L33 by pinning both ipywidgets AND jupyterlab_widgets (the frontend package).

This is a very nasty workaround that should go away.

Anyway, the issue is addressed with voila=0.5.0a5. We need to rebuild Voici against that version of Voila for it to be resolved in Voici. Then we can remove the nasty workaround in the Voici codebase.

Problem is we are stuck with voila=0.5.0a4 while jupyterlite still builds against JupyterLab 3. But this should be resolved by jupyterlite/jupyterlite#1019.

Sorry for the whole mess. But again, Voici is still very much work in progress and not stabilized, same for Voila 0.5.0 alpha.

TLDR: pin ipywidgets=8.0.6 and jupyterlab_widgets=3.0.7 for now, while waiting for official Voila=0.5.0 and jupyterlite=2.0.0

@jsignell
Copy link
Author

jsignell commented Aug 3, 2023

Sorry for the whole mess. But again, Voici is still very much work in progress and not stabilized, same for Voila 0.5.0 alpha.

Yes! I am super excited to push on this and see what I can get working. I really appreciate the support and hope my issues aren't too distracting.

@jsignell
Copy link
Author

jsignell commented Aug 3, 2023

That worked!! https://jsignell.github.io/voici/voici/render/fires.html is rendering!

@martinRenou
Copy link
Member

This should be resolved now in the latest versions of Voila and Voici

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants