-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Error with Jinja2 3.1.5 and new Plotly 6.0.0 #5055
Comments
There's an analogous piece of code in the documentation here: https://plotly.com/python/dropdowns/#graph-selection-dropdowns-in-jinja I just confirmed that it works with Plotly 6.0.0 and Jinja2 3.1.5 A key difference between the example and your approach appears to be that the example loads all the figures into a dictionary and then runs them through template.render just once. You might see 1) if loading a data_for_jinja dict with all your figs and rendering just once works around the problem and 2) if modifying the example to iteratively render and create a new template reproduces the problem. It might also be diagnostic to strip the template down to just, say,
and then write it to disk at the end of each iteration of the loop. Looking at the version that jinja reports to be an invalid template might reveal the offending output -- perhaps some escape character or the like that is making the special jinja braces invisible -- and then it would be clear exactly how to_html and jinja are in conflict. What kind of figure(s) cause this crash? |
hi @bsense-rius - as @rl-utility-man says, it would help a lot if you could strip this down to a minimal example (the two-figure page they show would be great). thanks - @gvwilson |
I tested a minimal example of a very simple charts (two cosines) and it still fails. The first iteration runs fine but not the second However, if i follow the advice of @rl-utility-man by just running the render once, it works with simple and complex charts. I am happy that I found a solution, but on the other hand I am not totally confortable because I was not able to tell what was going under the hood for that "error". |
@bsense-rius If you share your minimal example, the Plotly team and community may be able to tell what was going under the hood for that error. |
Dear community,
Scope
Since few days ago I had a notebook in sagemaker studio (with sagemaker-distribution 2.2.2) that ran smoothly without issues with Jinja2 3.1.5 and Plotly 5.24.1 that used plotly's to_html().
17 days ago after an update of sagemaker distribution 2.2.2, plotly 5.24.1 was upgraded to plotly 6.0,0, amongst several other libaries. Our code stopped working. We ensured that the issue was with plotly 6.0.0 by going to our google colab instance that had plotly 5.24.1 with our code also runnining without issues. BUT when we installed package plotly 6.0.0 it stopped working with the very same error.
Error details
We use a Jinja2 template with several placeholders for plotly charts that are updated in a while loop. Only the first iteration over the template works, the second is failing with the following error.
As you can see below the code is pretty straight forward: We init the Jinja2 Environment objects and in the main body we update the htmlTemplate with plotly's figure to_html(),
First iteration is correct, but next one just returns the from_string() error shown above.
Conclusion
It seems that there might be a kind of change in the to_html() or in the figure object itself that fools Jinja2's from_sting in the next loop iteration.
Thank you very much!
The text was updated successfully, but these errors were encountered: