Skip to content

docs: Update README with start_sync_server section#466

Merged
camdecoster merged 2 commits into
masterfrom
cam/update-readme-start_sync_server
Jul 6, 2026
Merged

docs: Update README with start_sync_server section#466
camdecoster merged 2 commits into
masterfrom
cam/update-readme-start_sync_server

Conversation

@camdecoster

Copy link
Copy Markdown
Contributor

Description

Update the README to include section about keeping Chrome running. Also fix syntax issues in examples.

Changes

  • Update README

Notes

  • start_sync_server is undocumented at the moment
  • I mentioned it in this issue report to try to unblock some users

Comment thread src/py/README.md
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"})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"})

Comment thread src/py/README.md
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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread src/py/README.md Outdated
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/py/README.md Outdated
)
```

### Keeping Chrome warm across calls

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Keeping Chrome warm across calls
### Generate multiple images faster by reusing the same Chrome instance

Comment thread src/py/README.md Outdated
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()`:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()`:

Comment thread src/py/README.md Outdated
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/py/README.md Outdated
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

@emilykl emilykl Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/py/README.md Outdated
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).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
emilykl previously approved these changes Jul 6, 2026
@camdecoster camdecoster merged commit 11dae23 into master Jul 6, 2026
4 checks passed
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