-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Switch to use anywidget #4823
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
Switch to use anywidget #4823
Changes from 1 commit
8a148f2
e21e3d7
d5d245c
6355ee4
3abdc7f
88b327e
70d536f
3b9c192
a338e6f
aaefdaf
ebba1c5
6d2a372
b27643d
d4277ac
e7b6d7a
590a4db
cd7d587
4f2ce95
cc77778
23f387a
c53835e
0c9ffc9
0f16f0c
d1e24db
5eff0ca
195ea4e
ce96898
a3d8650
3bc3535
b5870e8
9302d29
a60e803
54d9fe4
204b052
263ef26
846e7b5
08d8052
28b27af
eb70d86
a911f53
2a7208f
45fca22
cae0088
93210e6
f553634
7664ac9
3578bac
0920b9d
2dbdcea
612ceec
cb488ff
4096595
20886ef
f8fe306
35f848b
3f6c8f7
5b97f05
3b94298
513798b
cede4e1
a80250d
99013dc
4ab2a0c
39e65af
25cbf52
8e3354d
60cc98f
ce607bb
3d2a234
6d29ba6
21fa7d0
4bb303c
4759697
e399c2d
f6f2691
ee67f2e
97d6cb1
7f241f3
dc87b3c
22d90c4
bee13cd
946590f
3a85b8a
fc8eff2
c65ca44
6d3f0a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
import plotly | ||
import plotly.graph_objs as go | ||
from plotly.offline import get_plotlyjs_version | ||
from plotly import optional_imports | ||
|
||
import warnings | ||
import psutil | ||
|
||
jupyter_notebook = optional_imports.get_module("notebook") | ||
jupyter_lab = optional_imports.get_module("jupyterlab") | ||
|
||
|
||
def display_jupyter_version_warnings(): | ||
|
||
parent_process = psutil.Process().parent().cmdline()[-1] | ||
|
||
if "jupyter-notebook" in parent_process and jupyter_notebook.__version__ < "7": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move the if "jupyter-notebook" in parent_process:
jupyter_notebook = optional_imports.get_module("notebook")
if jupyter_notebook.__version__ < "7": and similar for I wonder about the existing optional import calls in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! I moved them into the if statements. I'm not sure about the other optional calls in that file but I can make an issue to investigate that more There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just made this issue: #4856 |
||
# Add warning about upgrading notebook | ||
warnings.warn( | ||
f"Plotly version >= 6 requires Jupyter Notebook >= 7 but you have {jupyter_notebook.__version__} installed.\n To upgrade Jupyter Notebook, please run `pip install notebook --upgrade`." | ||
) | ||
elif "jupyter-lab" in parent_process and jupyter_lab.__version__ < "3": | ||
# Add warning about upgrading jupyterlab | ||
warnings.warn( | ||
f"Plotly version >= 6 requires JupyterLab >= 3 but you have {jupyter_lab.__version__} installed. To upgrade JupyterLab, please run `pip install jupyterlab --upgrade`." | ||
) | ||
|
||
|
||
def validate_coerce_fig_to_dict(fig, validate): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,5 @@ matplotlib==3.9.2 | |
scikit-image==0.24.0 | ||
psutil==5.9.7 | ||
kaleido | ||
orjson==3.9.10 | ||
orjson==3.9.10 | ||
anywidget==0.9.13 |
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.
IDK how this would happen in practice, but in principle
.parent()
can return None which would make this fail. In that case I guess we aren't in a jupyter context so we can short-circuit the rest of this.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 added some code to address this! Let me know if you think there's a better approach than a try/except