We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
With newer versions of orjson, users need to specify the json engine explicitly (bug?)
Hey

I found out I get an
`AttributeError: partially initialized module 'orjson' has no attribute 'OPT_NON_STR_KEYS'`
if I don't specify this
`plotly.io.json.config.default_engine = 'orjson'`
when using orjson v3.6.6 (latest as of 25jan2022)

Also, additional note for whoever might have this issue: you don't need to uninstall orjson if you don't want to use it. just set the engine to 'json' explicitly. 

I'm using orjson because of the performance claims, although I ran some tests switching between the 2 engines and they seem to yield the same results: using go.Candlestick with 10000 candlesticks and some 4-5 indicators, getting ~0.8sec in each case for creating the plot. My purpose is to improve the dash server performace, but it seems it makes no difference (the web page still renders slower than the ticker even with 600 candles)




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `packages/python/plotly/_plotly_utils/optional_imports.py`
Content:
```
1 """
2 Stand-alone module to provide information about whether optional deps exist.
3 
4 """
5 from importlib import import_module
6 import logging
7 import sys
8 
9 logger = logging.getLogger(__name__)
10 _not_importable = set()
11 
12 
13 def get_module(name, should_load=True):
14     """
15     Return module or None. Absolute import is required.
16 
17     :param (str) name: Dot-separated module path. E.g., 'scipy.stats'.
18     :raise: (ImportError) Only when exc_msg is defined.
19     :return: (module|None) If import succeeds, the module will be returned.
20 
21     """
22     if name in sys.modules:
23         return sys.modules[name]
24     if not should_load:
25         return None
26     if name not in _not_importable:
27         try:
28             return import_module(name)
29         except ImportError:
30             _not_importable.add(name)
31         except Exception:
32             _not_importable.add(name)
33             msg = f"Error importing optional module {name}"
34             logger.exception(msg)
35
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/packages/python/plotly/_plotly_utils/optional_imports.py b/packages/python/plotly/_plotly_utils/optional_imports.py
--- a/packages/python/plotly/_plotly_utils/optional_imports.py
+++ b/packages/python/plotly/_plotly_utils/optional_imports.py
@@ -2,6 +2,7 @@
 Stand-alone module to provide information about whether optional deps exist.
 
 """
+
 from importlib import import_module
 import logging
 import sys
@@ -19,10 +20,9 @@
     :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)
@@ -32,3 +32,5 @@
             _not_importable.add(name)
             msg = f"Error importing optional module {name}"
             logger.exception(msg)
+
+    return None

{"golden_diff": "diff --git a/packages/python/plotly/_plotly_utils/optional_imports.py b/packages/python/plotly/_plotly_utils/optional_imports.py\n--- a/packages/python/plotly/_plotly_utils/optional_imports.py\n+++ b/packages/python/plotly/_plotly_utils/optional_imports.py\n@@ -2,6 +2,7 @@\n Stand-alone module to provide information about whether optional deps exist.\n \n \"\"\"\n+\n from importlib import import_module\n import logging\n import sys\n@@ -19,10 +20,9 @@\n     :return: (module|None) If import succeeds, the module will be returned.\n \n     \"\"\"\n-    if name in sys.modules:\n-        return sys.modules[name]\n     if not should_load:\n-        return None\n+        return sys.modules.get(name, None)\n+\n     if name not in _not_importable:\n         try:\n             return import_module(name)\n@@ -32,3 +32,5 @@\n             _not_importable.add(name)\n             msg = f\"Error importing optional module {name}\"\n             logger.exception(msg)\n+\n+    return None\n", "issue": "With newer versions of orjson, users need to specify the json engine explicitly (bug?)\nHey\r\n\r\nI found out I get an\r\n`AttributeError: partially initialized module 'orjson' has no attribute 'OPT_NON_STR_KEYS'`\r\nif I don't specify this\r\n`plotly.io.json.config.default_engine = 'orjson'`\r\nwhen using orjson v3.6.6 (latest as of 25jan2022)\r\n\r\nAlso, additional note for whoever might have this issue: you don't need to uninstall orjson if you don't want to use it. just set the engine to 'json' explicitly. \r\n\r\nI'm using orjson because of the performance claims, although I ran some tests switching between the 2 engines and they seem to yield the same results: using go.Candlestick with 10000 candlesticks and some 4-5 indicators, getting ~0.8sec in each case for creating the plot. My purpose is to improve the dash server performace, but it seems it makes no difference (the web page still renders slower than the ticker even with 600 candles)\r\n\r\n\r\n\n", "before_files": [{"content": "\"\"\"\nStand-alone module to provide information about whether optional deps exist.\n\n\"\"\"\nfrom importlib import import_module\nimport logging\nimport sys\n\nlogger = logging.getLogger(__name__)\n_not_importable = set()\n\n\ndef get_module(name, should_load=True):\n    \"\"\"\n    Return module or None. Absolute import is required.\n\n    :param (str) name: Dot-separated module path. E.g., 'scipy.stats'.\n    :raise: (ImportError) Only when exc_msg is defined.\n    :return: (module|None) If import succeeds, the module will be returned.\n\n    \"\"\"\n    if name in sys.modules:\n        return sys.modules[name]\n    if not should_load:\n        return None\n    if name not in _not_importable:\n        try:\n            return import_module(name)\n        except ImportError:\n            _not_importable.add(name)\n        except Exception:\n            _not_importable.add(name)\n            msg = f\"Error importing optional module {name}\"\n            logger.exception(msg)\n", "path": "packages/python/plotly/_plotly_utils/optional_imports.py"}], "after_files": [{"content": "\"\"\"\nStand-alone module to provide information about whether optional deps exist.\n\n\"\"\"\n\nfrom importlib import import_module\nimport logging\nimport sys\n\nlogger = logging.getLogger(__name__)\n_not_importable = set()\n\n\ndef get_module(name, should_load=True):\n    \"\"\"\n    Return module or None. Absolute import is required.\n\n    :param (str) name: Dot-separated module path. E.g., 'scipy.stats'.\n    :raise: (ImportError) Only when exc_msg is defined.\n    :return: (module|None) If import succeeds, the module will be returned.\n\n    \"\"\"\n    if not should_load:\n        return sys.modules.get(name, None)\n\n    if name not in _not_importable:\n        try:\n            return import_module(name)\n        except ImportError:\n            _not_importable.add(name)\n        except Exception:\n            _not_importable.add(name)\n            msg = f\"Error importing optional module {name}\"\n            logger.exception(msg)\n\n    return None\n", "path": "packages/python/plotly/_plotly_utils/optional_imports.py"}]}