docs: Update README with start_sync_server section#466
Merged
Conversation
emilykl
reviewed
Jul 6, 2026
Comment on lines
+70
to
+76
| import asyncio | ||
| import kaleido | ||
|
|
||
| async with kaleido.Kaleido(n=4, timeout=90) as k: | ||
| # n is number of processes | ||
| await k.write_fig(fig, path="./", opts={"format":"jpg"}) | ||
| async def main(): | ||
| async with kaleido.Kaleido(n=4, timeout=90) as k: | ||
| # n is number of processes | ||
| await k.write_fig(fig, path="./", opts={"format": "jpg"}) |
Collaborator
There was a problem hiding this comment.
Suggested change
| import asyncio | |
| import kaleido | |
| async with kaleido.Kaleido(n=4, timeout=90) as k: | |
| # n is number of processes | |
| await k.write_fig(fig, path="./", opts={"format":"jpg"}) | |
| async def main(): | |
| async with kaleido.Kaleido(n=4, timeout=90) as k: | |
| # n is number of processes | |
| await k.write_fig(fig, path="./", opts={"format": "jpg"}) | |
| import asyncio | |
| import kaleido | |
| import plotly.express as px | |
| async def main(): | |
| # n is number of processes | |
| async with kaleido.Kaleido(n=4, timeout=90) as k: | |
| # fig is a plotly figure object | |
| fig = px.scatter(x=[1, 2, 3, 4], y=[2, 1, 4, 3]) | |
| await k.write_fig(fig, path="./", opts={"format": "jpg"}) |
emilykl
reviewed
Jul 6, 2026
Comment on lines
+78
to
+81
| # You can also use Kaleido.write_fig_from_object, where fig_objects is | ||
| # an iterable of dicts each expanded to the write_fig arguments (fig, | ||
| # path, opts, topojson): | ||
| await k.write_fig_from_object(fig_objects) |
Collaborator
There was a problem hiding this comment.
Suggestion to include code which declares fig_objects for clarity on the exact structure of the object.
Suggested change
| # You can also use Kaleido.write_fig_from_object, where fig_objects is | |
| # an iterable of dicts each expanded to the write_fig arguments (fig, | |
| # path, opts, topojson): | |
| await k.write_fig_from_object(fig_objects) | |
| # You can also use Kaleido.write_fig_from_object, where fig_objects is | |
| # an iterable of dicts each expanded to the write_fig arguments (fig, | |
| # path, opts, topojson): | |
| fig_objects = [ | |
| { | |
| "fig": px.scatter(x=[1, 2, 3, 4], y=[2+i, 1+i, 4+i, 3+i]), | |
| "path": f"fig_{i}.jpg", | |
| "opts": {"format": "jpg"}, | |
| } for i in range(10) | |
| ] | |
| await k.write_fig_from_object(fig_objects) |
emilykl
reviewed
Jul 6, 2026
Comment on lines
+89
to
+97
| # - fig: A single plotly figure or an iterable. | ||
| # - path: A directory (names auto-generated based on title) | ||
| # or a single file. | ||
| # - opts: A dictionary with image options: | ||
| # `{"scale":..., "format":..., "width":..., "height":...}` | ||
| # - cancel_on_error: If False (default), errors during rendering are collected | ||
| # and returned as a tuple after all figures are attempted. | ||
| # If True, the first error is raised immediately and any | ||
| # remaining renders are cancelled. |
Collaborator
There was a problem hiding this comment.
Suggested change
| # - fig: A single plotly figure or an iterable. | |
| # - path: A directory (names auto-generated based on title) | |
| # or a single file. | |
| # - opts: A dictionary with image options: | |
| # `{"scale":..., "format":..., "width":..., "height":...}` | |
| # - cancel_on_error: If False (default), errors during rendering are collected | |
| # and returned as a tuple after all figures are attempted. | |
| # If True, the first error is raised immediately and any | |
| # remaining renders are cancelled. | |
| # - fig: (required) A single plotly figure or an iterable. | |
| # - path: (optional) A directory (names auto-generated based on title) | |
| # or a single file. | |
| # - opts: (optional) A dictionary with image options: | |
| # `{"scale":..., "format":..., "width":..., "height":...}` | |
| # - cancel_on_error: (optional) If False (default), errors during rendering are collected | |
| # and returned as a tuple after all figures are attempted. | |
| # If True, the first error is raised immediately and any | |
| # remaining renders are cancelled. |
emilykl
reviewed
Jul 6, 2026
| ) | ||
| ``` | ||
|
|
||
| ### Keeping Chrome warm across calls |
Collaborator
There was a problem hiding this comment.
Suggested change
| ### Keeping Chrome warm across calls | |
| ### Generate multiple images faster by reusing the same Chrome instance |
emilykl
reviewed
Jul 6, 2026
Comment on lines
+125
to
+127
| Call `kaleido.start_sync_server()` once at the top of your script to keep | ||
| a single Chrome instance warm and reuse it across all subsequent sync | ||
| calls, including `fig.write_image()`: |
Collaborator
There was a problem hiding this comment.
Suggested change
| Call `kaleido.start_sync_server()` once at the top of your script to keep | |
| a single Chrome instance warm and reuse it across all subsequent sync | |
| calls, including `fig.write_image()`: | |
| Call `kaleido.start_sync_server()` once at the top of your script to start | |
| a single Chrome instance and reuse it across all subsequent sync | |
| calls, including `fig.write_image()`: |
emilykl
reviewed
Jul 6, 2026
| By default, each call to `kaleido.write_fig_sync`, `kaleido.calc_fig_sync`, | ||
| or Plotly's `fig.write_image()` launches a fresh Chrome instance, renders | ||
| the figure, and shuts Chrome down again. If you're exporting many figures | ||
| in one script, the per-call Chrome startup and shutdown cost will |
Collaborator
There was a problem hiding this comment.
Suggested change
| in one script, the per-call Chrome startup and shutdown cost will | |
| in one script, the per-call Chrome startup and shutdown delay will |
emilykl
reviewed
Jul 6, 2026
Comment on lines
+145
to
+146
| The `page_generator` argument takes a `kaleido.PageGenerator()` to customize versions. | ||
| Normally, kaleido looks for an installed copy of plotly and uses that version. You can pass |
Collaborator
There was a problem hiding this comment.
Suggested change
| The `page_generator` argument takes a `kaleido.PageGenerator()` to customize versions. | |
| Normally, kaleido looks for an installed copy of plotly and uses that version. You can pass | |
| The `page_generator` argument takes a `kaleido.PageGenerator()` to customize which versions | |
| of plotly.js, MathJax, and other scripts are used when generating an image. | |
| If plotly is installed, kaleido defaults to the version of plotly.js contained in that package. You can pass |
emilykl
reviewed
Jul 6, 2026
Comment on lines
147
to
148
| `kaleido.PageGenerator(force_cdn=True)` to force use of a CDN version of plotly (the | ||
| default if plotly is not installed). |
Collaborator
There was a problem hiding this comment.
Suggested change
| `kaleido.PageGenerator(force_cdn=True)` to force use of a CDN version of plotly (the | |
| default if plotly is not installed). | |
| `kaleido.PageGenerator(force_cdn=True)` to force use of a CDN version of plotly (which is | |
| the default behavior if plotly is not installed). |
emilykl
previously approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Update the README to include section about keeping Chrome running. Also fix syntax issues in examples.
Changes
Notes
start_sync_serveris undocumented at the moment