-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
Improve notebook resource and extension loading #4752
Conversation
pre-commit.ci autofix |
Codecov Report
@@ Coverage Diff @@
## main #4752 +/- ##
==========================================
- Coverage 83.29% 83.12% -0.17%
==========================================
Files 268 268
Lines 37708 37709 +1
==========================================
- Hits 31409 31346 -63
- Misses 6299 6363 +64
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 8 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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 have reviewed the code, still need to test it.
I have tested in a variety of combinations of Notebook/Lab/vscode both with this PR and Panel 0.14. Where Panel 0.14 fails, this succeeds. Using an old notebook with Panel 0.14 loaded beforehand now loads correctly with this PR. The problem with the ordering of |
c4543cc
to
fe5579c
Compare
In the past we had two major issues with resource and extension loading in notebooks.
Problems
Multiple extension calls
To avoid embedding huge inline JS/CSS bundles multiple times we avoided embedding the extension multiple times. This however caused issues if you had multiple extension calls in one cell, e.g.:
OR
Properly educating users on these issues is basically impossible and it adds significant friction.
Version clashes
When a user upgrades from an older Bokeh/Panel version the autoload JS code would detect that an existing Bokeh version is present and skip loading of the newer Bokeh and Panel libraries. Since newer Bokeh model bundles rarely work with older Bokeh/Panel JS versions this would lead to an error and no output showing up.
This situation could occur both in JupyterLab, where multiple tabs could load different versions of Bokeh and therefore you would have to potentially clear out all existing notebooks (and reload the page) when upgrading to a new Bokeh/Panel version. However even in classic notebook you could run into this situation by opening an existing notebook which had an older version of the autoload JS code embedded into it.
The solution
Instead of skipping the autoload JS code when multiple extensions are run we instead always run it but do not include Bokeh and Panel bundles when run a second time. This means extra extensions can be loaded in a secondary call to the extension without including the entire bundle each time.
Additionally we now check that the Bokeh JS version matches what we expect and if it does not we go ahead and load the newer Bokeh/Panel bundles. Once loaded we restore the old version BUT store the newer versions in a
Bokeh.versions
object. When a component is rendered we then look up the correct Bokeh version to use for rendering.