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

Widget rendering in JupyterLab4 and JupyterNotebook7 #3823

Closed
kolibril13 opened this issue Aug 12, 2023 · 10 comments
Closed

Widget rendering in JupyterLab4 and JupyterNotebook7 #3823

kolibril13 opened this issue Aug 12, 2023 · 10 comments
Assignees
Labels

Comments

@kolibril13
Copy link

Today I was investigating how I can store the state of a widget with the latest Jupyter setups.

I wanted to know:

  • Can I save the widget state?
  • Is there an indicator that shows that the widget-kernel connection is lost?
  • Does the widget render correctly after restarting the Jupyter server?
  • Does the widget render correctly on sphinx with myst-nb?

And here is a summary of my findings:

image

used code:

import ipywidgets
ipywidgets.__version__

ipywidgets.widgets.Button(description="Hello World!")

Key findings from the above chart:

  1. Jupyter Notebook 6.5.4 is a setup where everything works great and there's the option "Save Notebook Widget State".
  2. jlab4 and jn7 have the new option "Save Widget State Automatically". I couldn't find out if that actually works or no.
  3. Jupyter VS Code cannot save widget states, and that's also not planned Save notebook widget state microsoft/vscode-jupyter#4404 .
  4. When I shut down the jupyter server and restart it, the jlab4 and nb7 console says "Error: widget model not found".
    I think making widget rendering possible after a notebook restart in the latest Jupyter environments would be a fantastic improvement. This could impact the widget ecosystem in a very positive way, especially since numerous people in the community have reported similar widget model not found errors:
    Widget state not persisted after kernel restart #3758,
    ipywidgets not renderering without a kernel #3773,
    ipywidgets cannot render when connected to a kernel of another notebook #2628,
    Display image even when restarting notebook. #3183,
    In JupyterLab 4.02, ipywidgets throws error in console on saving widget state. #3790

https://discourse.jupyter.org/t/widgets-not-rendering-after-the-second-time-a-notebook-is-reopened/10631
https://discourse.jupyter.org/t/error-displaying-widget-model-not-found-geemap/11473

@jasongrout
Copy link
Member

jasongrout commented Aug 12, 2023

jlab4 and jn7 have the new option "Save Widget State Automatically". I couldn't find out if that actually works or no.

FYI, turning this option on saves the widget state when you save the notebook. Turning the option off means that when you save the notebook, the widget state is not saved with the notebook (so notebook files are smaller, for example).

However, I just verified your other point:

jlab4 and jn7 have the new option "Save Widget State Automatically". I couldn't find out if that actually works or no.

When I have a notebook with widget state saved, and try to open it in JupyterLab, the widget is not rendered. It should be rendered from the state saved in the notebook file, and I think that is what is happening in notebook 6.

@kolibril13
Copy link
Author

hi @ibdafna, I'm happy to see that you self-assigned to this issue!

I'm curious to understand this bug a bit better:

Currently, "Save Widget State Automatically" adds a lot of data like "ewogICJ2ZXJzaW9uIjogMywKICAic291..." into the "widgets": { section of the notebook.

That can increase the size of the notebook quite a bit (up to a few 100kBs) which is totally fine when there's actual information saved, but would be unnecessary clutter in case that it's just corrupted data that comes from a bug while saving the notebook.

So the question: Is this bug related to widget saving, or widget loading?

@gutow
Copy link

gutow commented Sep 8, 2023

So the question: Is this bug related to widget saving, or widget loading?

As noted in #3758, opening a notebook in NBClassic that was saved in JLab 4/Notebook 7 with automatic saving of widget states properly renders the widget state with the broken connection icons. This suggests the problem is a notebook parsing or internal JLab communications issue and not related to an error in the data saved.

@krassowski
Copy link

krassowski commented Sep 23, 2023

Since this looks like (it could be) JupyterLab 4 issue, I would suggest opening an issue against https://github.com/jupyterlab/jupyterlab :)

@dinohsu1019
Copy link

Still I am facing: Error displaying widget: model not found, with:
jupyterlab: 4.0.9
ipywidgets: 8.1.1
jupyterlab-widgets: 3.0.9
I failed to find any downgrades that work either.

Is there any update on this? I am quite bothered by this problem, some long running results should be retained in the ipywidgets objects, including Output(). Please help identify the root cause as a group, be it jupyterlab, ipywidgets, ipython, javescript file, or whatever, instead of passing the bucks around. Thanks again.

@kolibril13
Copy link
Author

kolibril13 commented Dec 5, 2023

@dinohsu1019 I can understand your frustration.
Passing the issue from one project to the next one is part of the process to investigate where this issue is coming from, and that takes time.
The Jupyter core-infrastructure is evolving quickly, and not every feature is immediately up-to-date.
If you want to use that feature, you can do so by downgrading to

python3.11 -m venv .venv && source .venv/bin/activate
pip install notebook==6.5.6

@maartenbreddels
Copy link
Member

Note that #3866 should fix this.

@kolibril13
Copy link
Author

Really happy this is solved now, thanks everyone for making this possible!

@maartenbreddels
Copy link
Member

Thank you for the feedback ❤️

@RKwork85
Copy link

我仍然面临: Error Displaying widget: model not found, with: jupyterlab: 4.0.9 ipywidgets: 8.1.1 jupyterlab-widgets: 3.0.9 我也找不到任何有效的降级。

这方面有更新吗?我对这个问题很困扰,一些长时间运行的结果应该保留在 ipywidgets 对象中,包括 Output()。请作为一个整体帮助确定根本原因,无论是 jupyterlab、ipywidgets、ipython、javescript 文件还是其他文件,而不是互相推诿。再次感谢。

我仍然面临: Error Displaying widget: model not found, with: jupyterlab: 4.0.9 ipywidgets: 8.1.1 jupyterlab-widgets: 3.0.9 我也找不到任何有效的降级。

这方面有更新吗?我对这个问题很困扰,一些长时间运行的结果应该保留在 ipywidgets 对象中,包括 Output()。请作为一个整体帮助确定根本原因,无论是 jupyterlab、ipywidgets、ipython、javescript 文件还是其他文件,而不是互相推诿。再次感谢。

Quite agree !!!!!!!!!!!!!!!!!!!

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

No branches or pull requests

8 participants