-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Labels
Description
Situation
- A nonexistent filepath is passed as the
plotlyjs
argument when creating a Kaleido instance. Theplotlyjs
argument is supposed to be either a local path or a URL which points to the Plotly.js script.
Expected behavior
Kaleido()
raises an exception if the plotlyjs
path does not point to an actual file
Actual behavior
Kaleido is instantiated successfully. Later, when trying to generate an image, the generation fails with a JS Plotly is not defined
error:
kaleido._kaleido_tab.JavascriptError: {'result': {'type': 'object', 'subtype': 'error', 'className': 'ReferenceError', 'description': 'ReferenceError: Plotly is not defined\n at Object.render [as plotly] (file:///Users/ekl/code/plotly.py/venv/plotly.py/lib/python3.12/site-packages/kaleido/vendor/kaleido_scopes.js:3021:18)\n at <anonymous>:1:48', 'objectId': '7443417724967587290.1.1'}, 'exceptionDetails': {'exceptionId': 1, 'text': 'Uncaught', 'lineNumber': 3020, 'columnNumber': 17, 'scriptId': '7', 'stackTrace': {'callFrames': [{'functionName': 'render', 'scriptId': '7', 'url': 'file:///Users/ekl/code/plotly.py/venv/plotly.py/lib/python3.12/site-packages/kaleido/vendor/kaleido_scopes.js', 'lineNumber': 3020, 'columnNumber': 17}, {'functionName': '', 'scriptId': '11', 'url': '', 'lineNumber': 0, 'columnNumber': 47}]}, 'exception': {'type': 'object', 'subtype': 'error', 'className': 'ReferenceError', 'description': 'ReferenceError: Plotly is not defined\n at Object.render [as plotly] (file:///Users/ekl/code/plotly.py/venv/plotly.py/lib/python3.12/site-packages/kaleido/vendor/kaleido_scopes.js:3021:18)\n at <anonymous>:1:48', 'objectId': '7443417724967587290.1.2'}}}
Code to reproduce:
import asyncio
import kaleido
import plotly.graph_objects as go
asyncio.run(
kaleido.write_fig(
go.Figure([go.Bar(x=[1, 2, 3], y=[4, 5, 6])]),
"bar_chart.png",
kopts={"plotlyjs": "path/to/file/which/does/not/exist.js"}
)
)