Skip to content

Commit

Permalink
Merge pull request #4562 from plotly/fix-3567-orjson-import
Browse files Browse the repository at this point in the history
Fix `orjson` loading error
  • Loading branch information
emilykl authored Apr 15, 2024
2 parents 586aeeb + 4f72c59 commit b909d48
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ orjson
dash-bio
jinja2<3.1
parmed<=3.4.4; python_version<"3.8"
dask==2022.2.0
polars
dask==2022.2.0
8 changes: 5 additions & 3 deletions packages/python/plotly/_plotly_utils/optional_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Stand-alone module to provide information about whether optional deps exist.
"""

from importlib import import_module
import logging
import sys
Expand All @@ -19,10 +20,9 @@ def get_module(name, should_load=True):
:return: (module|None) If import succeeds, the module will be returned.
"""
if name in sys.modules:
return sys.modules[name]
if not should_load:
return None
return sys.modules.get(name, None)

if name not in _not_importable:
try:
return import_module(name)
Expand All @@ -32,3 +32,5 @@ def get_module(name, should_load=True):
_not_importable.add(name)
msg = f"Error importing optional module {name}"
logger.exception(msg)

return None
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.25.1
tenacity==6.2.0
pytest==6.2.3
pytest==8.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ numpy==1.20.2
xarray==0.17.0
statsmodels
Pillow==8.2.0
pytest==6.2.3
pytest==8.1.1
pytz==2021.1
ipython[all]==7.22.0
ipywidgets==8.0.2
Expand Down

0 comments on commit b909d48

Please sign in to comment.