Skip to content

Upgrade to kaleido 1.0 / plotly 6 - #7623

Closed
stefanv wants to merge 18 commits into
scikit-image:pre-megamove-integrationfrom
stefanv:kaleido-1.0.0
Closed

stefanv wants to merge 18 commits into
scikit-image:pre-megamove-integrationfrom
stefanv:kaleido-1.0.0

Conversation

@stefanv

@stefanv stefanv commented Dec 5, 2024

Copy link
Copy Markdown
Member

No description provided.

@stefanv stefanv added the 🔧 type: Maintenance Refactoring and maintenance of internals label Dec 5, 2024
@stefanv

stefanv commented Dec 6, 2024 •

Copy link
Copy Markdown
Member Author

Waiting on plotly/plotly.py#4926

@stefanv

stefanv commented Jan 24, 2025

Copy link
Copy Markdown
Member Author

No new release forthcoming so far :(

@stefanv
stefanv force-pushed the kaleido-1.0.0 branch 2 times, most recently from 230f10c to 1bb887f Compare January 28, 2025 19:57
@stefanv

stefanv commented Feb 3, 2025

Copy link
Copy Markdown
Member Author

xref: plotly/kaleido#242

@ayjayt

ayjayt commented Feb 24, 2025 •

Copy link
Copy Markdown

Hi thread! @stefanv

There are new pre-releases slated on github of kaleido: https://github.com/plotly/Kaleido/tree/latest-tag

Once Kaleido >= v1.0.0rc1 is integrated into plotly.py (for figure.write_figure(PATH) shortcut API), it will be released as v1.0.0 official.

But the base Kaleido API is stable and can also be used like this:

import kaleido
kaleido.write_fig_sync(some_figure, path="./output./")

Here are some more examples:
https://github.com/plotly/Kaleido/blob/master/src/py/docs/examples.md
The new API enables multi-processor and more memory efficient processing, which may be of interest for this project.

The new kaleido release requires a chromium-ish browser (chromium, chrome, edge) to be installed and accesible.
This is also possible from a CLI that comes with kaleido:

kaleido_get_chrome --help

That command also uses tested chromiums in case new versions introduce bugs (they do sometimes).

Feel free to @ me for any help.

@stefanv

stefanv commented Feb 26, 2025 •

Copy link
Copy Markdown
Member Author

Thansk @ayjayt! Are you planning to make a new RC release on PyPI so we can try it?

@ayjayt

ayjayt commented Feb 26, 2025

Copy link
Copy Markdown

If I convince the rest of the team the documentation that I wrote is sufficient for a rc I think we can push the next rc to pypi, I can bring it up tomorrow.

The rc will get bumped to a full release once plotly.py finishes integration and the technical writer approves, I imagine.

There is also a branch on github called latest-tag which follows the latest release (pre or full), so any eager users can install with:

pip install git+https://github.com/plotly/kaleido@latest-tag#subdirectory=src/py

@stefanv

stefanv commented Feb 26, 2025

Copy link
Copy Markdown
Member Author

Testing directly from gh is a bit finicky with our CI, but the last two commits here should take care of it.

@stefanv

stefanv commented Feb 26, 2025

Copy link
Copy Markdown
Member Author

@ayjayt Doesn't look like the plotly backend is picking up on kaleido rc6? It still talks about installing orca:

ImportError: orca and psutil are required to use the `sphinx-gallery-orca` renderer. See https://plotly.com/python/static-image-export/ for instructions on how to install orca. Alternatively, you can use the `sphinx-gallery` renderer (note that png thumbnails can only be generated with the `sphinx-gallery-orca` renderer).

See the failed "Test docs" CI entry above.

@ayjayt

ayjayt commented Feb 27, 2025 •

Copy link
Copy Markdown

Yes exactly, that's what I've failed to articulate.

The kaleido api is stable in kaleido>=v1.0.0rc1 as such:

import kaleido
kaleido.write_fig_sync(fig, path)

But until the plotly integration is done, this won't work:

import plotly
fig = ...
fig.write_image(path)

Once the plotly.py integration is finished and this shortcut function is back, v1.0.0 will be released.

@ayjayt

ayjayt commented Feb 27, 2025 •

Copy link
Copy Markdown

@stefanv, the kaleido api (not the plotly.Figure.write_image() shortcut) will be much faster and more memory efficient for batch processing and I imagine it will be a better choice for this project, but I'm assuming there are quite a few images here.

@ayjayt

ayjayt commented Feb 27, 2025 •

Copy link
Copy Markdown

My personal goal in this exercise was to reasonably enable making movies from plotly figures.

Plotly animations work for simple graphs, but the new kaleido allows to output 100's of frames (without OOM killer, and in a reasonable timeframe) and string them into an MP4, create data movies:

324344285-dc13af46-5e78-4c4d-a03c-94d6cc40e554.mp4

@stefanv

stefanv commented Feb 27, 2025

Copy link
Copy Markdown
Member Author

That's awesome :)

My goal is just to get the skimage docs to build again, without pinning an ancient version of kaleido, which is not currently possible :(

@ayjayt

ayjayt commented Feb 27, 2025

Copy link
Copy Markdown

@stefanv I can probably fix the PR, give me a day, I should be able to do it in <15 minutes with a grep

@stefanv

stefanv commented Feb 27, 2025

Copy link
Copy Markdown
Member Author

Well, I think we don't want to use unintuitive or non-standard API in our examples, so we may need to wait for the plotly integration, or figure out a backend hack.

@ayjayt

ayjayt commented Feb 27, 2025

Copy link
Copy Markdown

I'll keep you posted

@stefanv

stefanv commented Feb 27, 2025

Copy link
Copy Markdown
Member Author

Thanks!

@stefanv

stefanv commented Mar 7, 2025

Copy link
Copy Markdown
Member Author

@ayjayt Any update on the kaleido / plotly integration and release?

@ayjayt

ayjayt commented Mar 11, 2025 •

Copy link
Copy Markdown

Hi @stefanv, there is plotly/plotly.py#5062 which is slated for 6.1.0 AFAIK (this month)

I will be pushing forward on some of their tasks today, let me know if there is anything I can do for you in the meantime.

@stefanv

stefanv commented Mar 17, 2025

Copy link
Copy Markdown
Member Author

No go with latest plotly.

@stefanv

stefanv commented Apr 21, 2025

Copy link
Copy Markdown
Member Author

@ayjayt Are you still interested in this problem? The current failure is:

        AttributeError: module 'kaleido' has no attribute 'calc_fig_sync'

@ayjayt

ayjayt commented Apr 21, 2025

Copy link
Copy Markdown

Yes this is still in progress! Some newer releases are out and official releases are just making their way through the pipeline. It's mainly fixing up documentation and integrating with Plotly! I'll give a more thorough review of issues this evening.

@stefanv
stefanv marked this pull request as ready for review July 16, 2025 09:07
@stefanv

stefanv commented Nov 4, 2025 •

Copy link
Copy Markdown
Member Author

choreographer.browsers._errors.BrowserFailedError: ('The browser seemed to close immediately after starting.', 'You can set the logging.Logger level lower to see more output.', 'You may try installing a known working copy of Chrome by running ', '$ choreo_get_chrome. It may be your copy auto-updated.')

I don't really like that it seems to be so picky about the Chrome version required.

@ayjayt

ayjayt commented Nov 26, 2025 •

Copy link
Copy Markdown

choreographer.browsers._errors.BrowserFailedError: ('The browser seemed to close immediately after starting.', 'You can set the logging.Logger level lower to see more output.', 'You may try installing a known working copy of Chrome by running ', '$ choreo_get_chrome. It may be your copy auto-updated.')

I don't really like that it seems to be so picky about the Chrome version required.

Neither am I.

Plotly used to build and ship a chrome engine inside kaleido but that become infeasible when the binary got too big to host on package distributors.

I am building testing and a possible long term solution for this but it's sort of intractable, given browsers are our #1 interactive rendering engines and nobody ships a browser architected to use it in parts.

That said, I don't think linux-arm has a significant user base for the package. I'm not sure what you're seeing, but we don't get ANY issues for it outside of this one. And I would assume Google feels the same way, or else they would be offering a version of it for testing.

I could be wrong though, and I am still eyeing ways to solve it.

@stefanv

stefanv commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

Maybe could try and debug the issue on a Raspberry Pi? I'd recommend adding an M.2 NVME hat, it really helps with disk access.

@stefanv

stefanv commented May 26, 2026

Copy link
Copy Markdown
Member Author

@ayjayt What is the current status of the Kaleido porting effort?

@matthew-brett
matthew-brett changed the base branch from main to pre-megamove-integration June 19, 2026 15:26
blink1073 added a commit to blink1073/scikit-image that referenced this pull request Sep 1, 2026
plotly_get_chrome's console script isn't reliably on PATH in this
job's shell: plotly and kaleido install cleanly, but the next step
fails with "plotly_get_chrome: command not found" (exit 127).

Match the GitHub Actions job instead, installing a real Chrome
through apt. This also addresses a standing preference for a
system-installed Chrome over plotly/kaleido's own fetch mechanism;
the earlier attempt at that in scikit-image#7623 used Ubuntu's `chromium-browser`,
which is a non-functional snap-transitional package, not a real
browser.

Assisted-by: Claude (Opus 5)
blink1073 added a commit to blink1073/scikit-image that referenced this pull request Sep 1, 2026
plotly_get_chrome's console script isn't reliably on PATH in this
job's shell: plotly and kaleido install cleanly, but the next step
fails with "plotly_get_chrome: command not found" (exit 127).

Match the GitHub Actions job instead, installing a real Chrome
through apt. This also addresses a standing preference for a
system-installed Chrome over plotly/kaleido's own fetch mechanism;
the earlier attempt at that in scikit-image#7623 used Ubuntu's `chromium-browser`,
which is a non-functional snap-transitional package, not a real
browser.

Assisted-by: Claude (Opus 5)
blink1073 added a commit to blink1073/scikit-image that referenced this pull request Sep 1, 2026
plotly_get_chrome's console script isn't reliably on PATH in this
job's shell: plotly and kaleido install cleanly, but the next step
fails with "plotly_get_chrome: command not found" (exit 127).

Match the GitHub Actions job instead, installing a real Chrome
through apt. This also addresses a standing preference for a
system-installed Chrome over plotly/kaleido's own fetch mechanism;
the earlier attempt at that in scikit-image#7623 used Ubuntu's `chromium-browser`,
which is a non-functional snap-transitional package, not a real
browser.

Assisted-by: Claude (Opus 5)
blink1073 added a commit to blink1073/scikit-image that referenced this pull request Sep 1, 2026
plotly_get_chrome's console script isn't reliably on PATH in this
job's shell: plotly and kaleido install cleanly, but the next step
fails with "plotly_get_chrome: command not found" (exit 127).

Match the GitHub Actions job instead, installing a real Chrome
through apt. This also addresses a standing preference for a
system-installed Chrome over plotly/kaleido's own fetch mechanism;
the earlier attempt at that in scikit-image#7623 used Ubuntu's `chromium-browser`,
which is a non-functional snap-transitional package, not a real
browser.

Assisted-by: Claude (Opus 5)
@blink1073 blink1073 closed this in a69547b Sep 2, 2026
matthew-brett pushed a commit that referenced this pull request Sep 4, 2026
Backport of a69547b onto pre-megamove-integration.

Fixes #8307. Closes #7623.

plotly 7.0.0 dropped support for kaleido 0.2.1, breaking every gallery
example that calls `plotly.io.show(fig)`. kaleido's 1.x rewrite needs
both a plotly>=6.1.1 floor and a headless Chrome install, which each CI
docs job now provides.

- Bumped `kaleido` from `==0.2.1` to `>=1.0`, so gallery examples render
through headless Chrome instead of the deprecated bundled binary.
- Bumped `plotly` from `>=5.20` to `>=6.1.1`, kaleido's own hardcoded
floor for compatibility with 1.x.
- The GitHub Actions docs job installs Chrome through apt: it runs on
arm64, where neither `plotly_get_chrome` nor
`browser-actions/setup-chrome` can provision Chrome (Chrome for Testing
has no Stable-channel linux-arm64 build yet).
- CircleCI's docs job installs Chrome through apt too, since
`plotly_get_chrome`'s console script isn't reliably on PATH there.

Docs CI tests.

<!-- See
https://scikit-image.org/docs/stable/development/contribute.html#documenting-changes
-->

```release-note
...
```

Assisted-by: Cursor <[email protected]>
mkcor pushed a commit to mkcor/scikit-image that referenced this pull request Nov 13, 2026
…ge#8308)

Backport of a69547b onto pre-megamove-integration.

Fixes scikit-image#8307. Closes scikit-image#7623.

plotly 7.0.0 dropped support for kaleido 0.2.1, breaking every gallery
example that calls `plotly.io.show(fig)`. kaleido's 1.x rewrite needs
both a plotly>=6.1.1 floor and a headless Chrome install, which each CI
docs job now provides.

- Bumped `kaleido` from `==0.2.1` to `>=1.0`, so gallery examples render
through headless Chrome instead of the deprecated bundled binary.
- Bumped `plotly` from `>=5.20` to `>=6.1.1`, kaleido's own hardcoded
floor for compatibility with 1.x.
- The GitHub Actions docs job installs Chrome through apt: it runs on
arm64, where neither `plotly_get_chrome` nor
`browser-actions/setup-chrome` can provision Chrome (Chrome for Testing
has no Stable-channel linux-arm64 build yet).
- CircleCI's docs job installs Chrome through apt too, since
`plotly_get_chrome`'s console script isn't reliably on PATH there.

Docs CI tests.

<!-- See
https://scikit-image.org/docs/stable/development/contribute.html#documenting-changes
-->

```release-note
...
```

Assisted-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 type: Maintenance Refactoring and maintenance of internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants