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

Broken ipywidgets interactivity in the Lorenz demo #54

Open
pierre-haessig opened this issue Sep 19, 2024 · 13 comments
Open

Broken ipywidgets interactivity in the Lorenz demo #54

pierre-haessig opened this issue Sep 19, 2024 · 13 comments

Comments

@pierre-haessig
Copy link
Contributor

This is a cross-post of the jupyterlite/pyodide-kernel#133 issue filed in the pyodide-kernel repo, to serve as a placeholder.

The specific symptom for try-jupyter is that the interactivity of the Lorenz attractor demo is broken. There is some strange/erratic behavior of ipywidgets inside JupyterLite which seemingly appeared this summer 2024.

@jtpio
Copy link
Member

jtpio commented Sep 19, 2024

Thanks @pierre-haessig for the report.

Also linking to jupyterlite/jupyterlite#1465 which looks related.

@jtpio
Copy link
Member

jtpio commented Sep 19, 2024

Wondering if this could be related to an ipywidgets release made this summer, which broke the use of interactive in JupyterLite.

@pierre-haessig
Copy link
Contributor Author

Thanks @pierre-haessig for the report.

Also linking to jupyterlite/jupyterlite#1465 which looks related.

Same symptoms indeed. Now that there a bug report for every jupyterlite-related repo!

@pierre-haessig
Copy link
Contributor Author

Wondering if this could be related to an ipywidgets release made this summer, which broke the use of interactive in JupyterLite.

Good question! Then only think I'm sure of is that ipywidgets still works in non jupyterlite environment.

@jtpio
Copy link
Member

jtpio commented Sep 20, 2024

Maybe it could be worth trying with ipywidgets<8.1.3? To check if this could be caused by jupyter-widgets/ipywidgets#3004, which changed a bit how the widgets are rendered in JupyterLab (and JupyterLite).

@pierre-haessig
Copy link
Contributor Author

Maybe it could be worth trying with ipywidgets<8.1.3? To check if this could be caused by jupyter-widgets/ipywidgets#3004, which changed a bit how the widgets are rendered in JupyterLab (and JupyterLite).

Good idea, but since pyodide bundles many packages in its distribution, is it just enough to change ipywidgets in requirements.txt? That is changing requirements to:

# Core modules (mandatory) → unchanged
jupyterlite-core==0.4.1
jupyterlab~=4.2.5
notebook~=7.2.2

# Python kernel (optional) → unchanged
jupyterlite-pyodide-kernel==0.4.2

....

# Python: ipywidget library for Jupyter notebooks (optional)
ipywidgets<8.1.3 # instead of ">=8.1.3,<9"

By the way, in try-jupyter, despite the fact it derives from jupyterlite/demo, I don't find requirements.txt but rather environment.yml. Is it interchangeable?

@jtpio
Copy link
Member

jtpio commented Sep 20, 2024

Yes, and maybe we can also try pinning jupyterlab-widgets to an older version. Also in the notebook update the cell to:

%pip install ipywidgets==8.1.2

By the way, in try-jupyter, despite the fact it derives from jupyterlite/demo, I don't find requirements.txt but rather environment.yml. Is it interchangeable?

Right, it's also fine to install dependencies in the build environment with conda / mamba, using an environment.yml.

@pierre-haessig
Copy link
Contributor Author

Yes, and maybe we can also try pinning jupyterlab-widgets to an older version

but I don't see jupyterlab-widgets in the in requirements.txt...

@jtpio
Copy link
Member

jtpio commented Sep 20, 2024

Right, it's a dependency of ipywidgets, but since ipywidgets defines the dependency as jupyterlab_widgets~=3.0.12 currently, it will likely grab a newer version even when pinning ipywidgets.

@pierre-haessig
Copy link
Contributor Author

Right, it's a dependency of ipywidgets, but since ipywidgets defines the dependency as jupyterlab_widgets~=3.0.12 currently, it will likely grab a newer version even when pinning ipywidgets

Do you mean that the version pinning should be done at the pip install stage with

%pip install ipywidgets==8.1.2 jupyterlab_widgets==3.0.12

(along with ipywidgets<8.1.3 in the requirements) or would it be too late in the pipeline?

@jtpio
Copy link
Member

jtpio commented Sep 20, 2024

I meant pinning jupyterlab_widgets in requirements.txt. In the notebook we only need to install ipywidgets.

pierre-haessig added a commit to pierre-haessig/pierre-notebooks that referenced this issue Sep 20, 2024
@pierre-haessig
Copy link
Contributor Author

OK, this is what I put in the requirements: https://github.com/pierre-haessig/pierre-notebooks/blob/main/requirements.txt

and here is the result: https://pierre-haessig.github.io/pierre-notebooks/lab/index.html?path=Frequency+regulation+nocode.ipynb

I rushed the test, so perhaps I missed something (normally I cleared browser cache, but sometimes...).

Also, what I don't understand is that

import ipywidgets
ipywidgets.__version__

report '8.1.5' despite https://github.com/pierre-haessig/pierre-notebooks/blob/main/requirements.txt

@bdcodebase
Copy link

If you need a workaround: Going back to Jupyterlite 0.3.0 made my interactive scripts work again. Some modules need to be installed on build side and on runtime side (see https://jupyterlite.readthedocs.io/en/stable/howto/configure/simple_extensions.html), which might result in different verions. As there is anonther issue with broken paths for widgetsnbextension (see jupyterlite/jupyterlite#1342), I added a requirements.txt on runtime side as well ("runtime-requirements.txt"), and use it to install the missing modules on runtime, without the need to adapt all scripts when something is changing again. See https://bdcodebase.github.io/JLdeployments/lab/index.html?path=DFT.ipynb for a (at least currently) working example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants