Skip to content
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

With newer versions of orjson, users need to specify the json engine explicitly (bug?) #3567

Closed
xucian opened this issue Jan 25, 2022 · 8 comments · Fixed by #4562
Closed
Assignees
Labels
bug something broken sev-1 blocker

Comments

@xucian
Copy link

xucian commented Jan 25, 2022

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)

@HeddeCrisp
Copy link

+1

@marcelo-ventura
Copy link

marcelo-ventura commented Jan 31, 2024

+1. App is presenting problems after a while. Not sure what's going on.

@Coding-with-Adam Coding-with-Adam added bug something broken sev-3 annoyance with workaround labels Feb 5, 2024
@noamgot
Copy link

noamgot commented Feb 11, 2024

+1. Happens to me when I use streamlit's st.plotly_chart (plotly v5.18.0)

@C0deBeez
Copy link

File "/.venv/lib/python3.11/site-packages/plotly/io/_json.py", line 146, in to_json_plotly
opts = orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY

This line of code may cause this issue

@ndrezn
Copy link
Member

ndrezn commented Mar 28, 2024

A fix may be using a regular import rather than using importlib to manage this package.

@ndrezn ndrezn assigned emilykl and unassigned T4rk1n Mar 28, 2024
@ndrezn
Copy link
Member

ndrezn commented Mar 28, 2024

To reproduce using Dash:

  1. pip install orjson
  2. Make a Dash app
  3. Trigger reload

If you look at network requests, it'll show this exact error.

@Coding-with-Adam Coding-with-Adam added sev-1 blocker and removed sev-3 annoyance with workaround labels Mar 28, 2024
@emilykl emilykl mentioned this issue Mar 29, 2024
5 tasks
@afeld
Copy link
Contributor

afeld commented Dec 1, 2024

Strangely, this error should have been fixed in Plotly v5.21.0, but I'm seeing it an environment with orjson v3.10.11. I'm not seeing it in other environments with the same version of Plotly with orjson v3.10.7 and v3.10.12. Neither the CHANGELOG nor diff suggest there was anything fixed in orjson around that setting from v3.10.11 to 3.10.12 🤨

@emilykl
Copy link
Contributor

emilykl commented Dec 2, 2024

Hi @afeld, thanks for the heads-up. I just did a quick test and I wasn't able to reproduce -- could you share replication steps, including your OS, Python version, and pip freeze of packages in your Python environment? If you can share that info I will try again to reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken sev-1 blocker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants