-
Notifications
You must be signed in to change notification settings - Fork 950
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
HTMLManager: Support both ipywidgets 7 and 8 models #3932
HTMLManager: Support both ipywidgets 7 and 8 models #3932
Conversation
95d5437
to
1fd5070
Compare
"@jupyter-widgets/controls": "^5.0.9", | ||
"@jupyter-widgets/controls7": "npm:@jupyter-widgets/[email protected]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I like this solution. It will solve many user's headaches. |
Nice work! In solara we use a similar trick with the npm alias, but we actually have to build 2 separate managers. I think this is a cleaner solution. |
Oh nice I did not know you tried that in Solara too! Note that we've done something similar in Voila 0.4.x but with just one manager: voila-dashboards/voila@5934c53, it's a bit different from the approach in this PR as it makes use of the lazy loading approach in the widgets register, so the widgets assets will load only upon request. I tried with latest Voila but things are more complicated there for some reason. |
In solara (because we run in the same process), we know beforehand at the server what the version of ipywidgets is, which allows for a different strategy. I don't think you need it here, but both these tricks allow for some fancy building/bundling options. |
Ah, that trick could probably be useful to me for Voila 0.5.x, I'll have to give it a try. Thanks for sharing! |
Currently, the HTML manager brings the jupyter-widgets front-end for ipywidgets 8, disregarding the version stored in the widget model.
This works fine in most cases, as long as the user did not store an ipywidgets 7 model that was making use of removed APIs.
This PR resolves this by lazily loading either the jupyter-widgets front-end for 7 or 8 depending on the version stored in the model. Similar to the approach taken in voila-dashboards/voila#1482
Testing nbconvert output with ipywidgets 7:
Testing nbconvert output with ipywidgets 8: