You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ValueError: Transform failed with error code 1: Failed to serialize document: Uncaught #41
Hi @wdecoster, thanks for the report. There is an open issue for figures that are "too large" (#19) but that results in a particular error that's different that what you're seeing.
My first question would be whether this happens with even small simple figures.
Here's one guess. When you build the PlotlyScope using the default constructor, Kaleido uses an online CDN location for the plotly.js bundle. So if the user doesn't have internet access (or is behind a proxy/firewall) then this kind of error could occur.
The plotlyjs argument/property to PlotlyScope can be used to point Kaleido to a local plotly.js bundle, which is what plotly.py does. If you're comfortable requiring plotly >= 4.9, then I would actually recommend letting plotly.py take care of interacting with kaleido, replacing what you have with
import plotly.io as pio
pio.write_image(fig, "output.png", engine="kaleido")
If you need to support older versions of plotly.py, then you could copy the kaleido initialization logic from
Great, thanks for the pointers. I'll make some changes and test that. It seems indeed to be the case that the user doesn't have internet access on this machine.
I made the changes you suggested (pio.write_image(fig, "output.png", engine="kaleido")), and at least a test where I unplugged my ethernet cable worked with the changes (but not without). I expect this also to fix the problem for the user who initially reported the error.
Activity
jonmmease commentedon Sep 17, 2020
Hi @wdecoster, thanks for the report. There is an open issue for figures that are "too large" (#19) but that results in a particular error that's different that what you're seeing.
My first question would be whether this happens with even small simple figures.
Here's one guess. When you build the
PlotlyScopeusing the default constructor, Kaleido uses an online CDN location for the plotly.js bundle. So if the user doesn't have internet access (or is behind a proxy/firewall) then this kind of error could occur.The
plotlyjsargument/property toPlotlyScopecan be used to point Kaleido to a local plotly.js bundle, which is what plotly.py does. If you're comfortable requiringplotly >= 4.9, then I would actually recommend letting plotly.py take care of interacting with kaleido, replacing what you have withIf you need to support older versions of plotly.py, then you could copy the kaleido initialization logic from
https://github.com/plotly/plotly.py/blob/8289eb1c85125e147c4ce14b56272ed50b99ef20/packages/python/plotly/plotly/io/_kaleido.py#L9-L17
which will configure the
PlotlyScopeto use the plotly.js bundle that is included with plotly.py.wdecoster commentedon Sep 18, 2020
Great, thanks for the pointers. I'll make some changes and test that. It seems indeed to be the case that the user doesn't have internet access on this machine.
nehaljwani commentedon Oct 1, 2020
I hit the same issue and copying the init logic worked in my case.
jonmmease commentedon Oct 1, 2020
@wdecoster, have you had a chance to try this?
wdecoster commentedon Oct 6, 2020
Sorry for the lack of feedback, I hope to get back to this next week.
changing the kaleido code for static image to use local plotly.js bundle
wdecoster commentedon Oct 9, 2020
I made the changes you suggested (
pio.write_image(fig, "output.png", engine="kaleido")), and at least a test where I unplugged my ethernet cable worked with the changes (but not without). I expect this also to fix the problem for the user who initially reported the error.Thanks!
jonmmease commentedon Oct 9, 2020
Great! Just make sure to update your minimum plotly.py version requirement to
plotly>=4.9.0.edit: Never mind, I see that you did in wdecoster/NanoPlot@9c840b7
wdecoster commentedon Oct 9, 2020
Took care of that, but thanks for the warning ;-)
Skip plotly static image generation on windows
Fix local (Windows) tests (#1302)