Skip to content

Fix spurious UserWarning from Kaleido when start_sync_server is active - #5809

Open
ioseba wants to merge 1 commit into
plotly:mainfrom
ioseba:fix-5786-kaleido-kopts-warning
Open

ioseba wants to merge 1 commit into
plotly:mainfrom
ioseba:fix-5786-kaleido-kopts-warning

Conversation

@ioseba

@ioseba ioseba commented Oct 10, 2026

Copy link
Copy Markdown

Link to issue

Closes #5786

Description of change

Avoid passing default kopts to calc_fig_sync() and write_fig_from_object_sync() when kaleido.start_sync_server() is running, preventing an unnecessary UserWarning: The kopts argument is ignored if using a server.

Demo

import plotly.express as px
import kaleido

fig = px.line(x=[0, 1], y=[0, 1])

kaleido.start_sync_server()
fig.write_image("output.png")  # Previously emitted UserWarning, now runs cleanly without warnings
kaleido.stop_sync_server()

Testing strategy

Added unit tests test_kaleido_sync_server_no_kopts_warning and test_kaleido_get_opts_helper in tests/test_optional/test_kaleido/test_kaleido.py. Verified that all 16 Kaleido tests pass cleanly.

Additional information (optional)

Plotly sets defaults.headers = {"X-Requested-With": "plotly.py"} by default to comply with OpenStreetMap tile policy. When Kaleido's sync server is running, options cannot be re-applied per request and Kaleido warns if kopts is provided. _get_kaleido_opts() now avoids passing default headers when the sync server is running (while continuing to pass them when the server is stopped or when custom headers/options are configured), eliminating spurious warnings.

Guidelines

This branch has not been deployed

No deployments
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.

[BUG]: Unnecessary UserWarning when using fig.write_image() with kaleido.start_sync_server()

1 participant