Skip to content

Fall back to placeholder PNG when Plotly static export fails - #582

Draft
kam-validmind wants to merge 2 commits into
mainfrom
kam/plotly-static-export-fallback
Draft

kam-validmind wants to merge 2 commits into
mainfrom
kam/plotly-static-export-fallback

Conversation

@kam-validmind

@kam-validmind kam-validmind commented Nov 4, 2026 •

Copy link
Copy Markdown

Problem

On Databricks serverless, Kaleido 1.x can't start Chrome (no root, missing system libs), so run_documentation_tests() fails as soon as a test produces a Plotly figure. Retries can also leave the cell hanging.

Change

  • If fig.to_image fails, log one warning and upload a placeholder PNG plus the Plotly JSON (json_image), so the platform can render the figure interactively.
  • After the first failure, skip Kaleido for later figures (no repeated retries).
  • VALIDMIND_PLOTLY_STATIC_EXPORT=false skips the attempt up front.
  • Placeholder images aren't sent to the LLM when generating test descriptions.

Notes

  • The backend /log_figure requires the image file, so a placeholder is uploaded rather than omitting the PNG. Anything using the PNG instead of the JSON (e.g. document export) shows the placeholder.
  • The fallback latches on any to_image exception, not only "Chrome is missing". If Chrome works but one figure fails for a one-off reason (Kaleido's 90-second render timeout on a very large figure, a Chrome crash), the rest of the session also gets placeholders, where before only that one test failed. This is deliberate: it keeps the Databricks case to a single attempt, and the one-off case is rare and comes with a warning naming the error. Alternatives if it bites: latch only on Kaleido/Chrome start-up errors, or after two or three consecutive failures.
  • Not tested on Databricks serverless; covered by unit tests with a mocked Kaleido failure.

Tests

tests/test_figure_static_export.py (4 tests).

Kaleido 1.x needs a working Chrome, which isn't available on Databricks
serverless. Instead of failing the run, upload the Plotly JSON with a
placeholder image, stop retrying after the first failure, and add
VALIDMIND_PLOTLY_STATIC_EXPORT=false to skip the attempt.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants