Don't warn about default kopts under a kaleido sync server - #5787
Open
jayzhou2309 wants to merge 2 commits into
Open
jayzhou2309 wants to merge 2 commits into
jayzhou2309 wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Link to issue
Closes #5786
Description of change
plotly.io.defaults.headersis always set (X-Requested-With: plotly.py, for the Open Street Map tile policy), so every export passes a non-emptykoptsto kaleido. Underkaleido.start_sync_server(), kaleido ignoreskoptsand warns whenever it is truthy. Sowrite_image,to_imageandwrite_imageswarned on every call, even when the user set no Kaleido options.This PR ignores that one warning only when
koptsholds nothing but plotly's default headers. Ifdefaults.plotlyjs,defaults.mathjaxor customdefaults.headersare set, the warning still fires, since those options really are dropped by the server. The default header moves to aDEFAULT_HEADERSconstant inplotly/io/_defaults.pyso the check can compare against it._sg_scraper.pyalready filters the same warning around its exports. It is unchanged here, because it passes user options to its own server.Kaleido has no public way to ask whether the sync server is running, so the other route (skip
koptswhen a server runs) would need its private_global_server.Demo
The script from the issue, with kaleido 1.3.0 and Chrome for Testing:
['The kopts argument is ignored if using a server.', 'The kopts argument is ignored if using a server.']for onewrite_imageand oneto_image[]Testing strategy
test_sync_server_no_kopts_warning_for_default_optionsstarts a real kaleido sync server and runsto_image,write_imageandwrite_imageswith default options. It fails on main (3 warnings) and passes here.test_sync_server_warns_when_options_are_ignoredsetsdefaults.plotlyjsand checks the warning still fires. It passes on main and here.tests/test_optional/test_kaleidoandtests/test_io: 301 passed, 8 skipped.ruff format --checkpasses on the changed files.ruff checkreports only the unusedimport osin_kaleido.py, which is already on main.AI disclosure
An AI agent (Claude Code) reproduced the issue, wrote the failing tests and the fix, and ran the commands above.
Guidelines
🤖 Written and posted by an AI agent (Claude Code) on behalf of @jayzhou2309.