-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Ensure hvplot.<ext> hooks are run on every import #1359
Conversation
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.
This is indeed quite a hammer but it's fixing a pretty bad issue (although it's hard to tell if it's the source of the majority of the reported problems). Not sure whether we could abuse Python's import system to achieve the same behavior, that would anyway be a big hammer too, and the one suggested at least scopes it to IPython usage.
I'd appreciate some comments in the code that explain why we have to resort to running code on each cell execution and removing modules from sys.modules
🙃
Isn't this a good example of why relying on imports with side-effects is a bad idea in Python? Should we consider migrating to a more explicit API, even if it'd mean having to type a bit more?
While this code change improves the situation, I still think there's a major UX issue. We're injecting crucial JS/CSS in the notebook, that can be easily removed by users by mistake, without letting them know that this is wrong. This is a general issue through HoloViz packages that needs .extension()
to be called (at least HoloViews and GeoViews display some logos). I would be in favor for showing a very explicit message. This might be a good topic for the next HoloViz meeting.
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.
We need to look more into how this is going to affect Polars' users. |
@hoxbro can you please review? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1359 +/- ##
==========================================
+ Coverage 87.39% 88.73% +1.34%
==========================================
Files 50 51 +1
Lines 7490 7592 +102
==========================================
+ Hits 6546 6737 +191
+ Misses 944 855 -89 ☔ View full report in Codecov by Sentry. |
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.
A few comments, you can ignore them if you don't agree 👍
oh my word, this explains so much, thanks for hunting it down... |
The
hvplot.<ext>
import mechanism is a convenient way to allow users to have to avoid running the holoviews/panel extensions. However since imports are cached only the first import actually embeds the extension JS code, meaning that if you re-run the cell(s) containingimport hvplot.pandas
(or some other integration) then the JS will no longer be available and on subsequent reloads/re-runs of the notebook plots may not appear. This probably accounts for most issues encountered and described in #1232.Here we add an IPython hook which simply deletes the modules before every cell execution. This is a big hammer but the best @hoxbro and I could find and at least it is restricted to IPython environments.