Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Kaleido v1 in Plotly.py #5062

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f0a78a6
small io refactor to support kaleido v1
emilykl Mar 4, 2025
a681c84
update kaleido tests to support kaleido v1
emilykl Mar 4, 2025
a7a6f24
Merge branch 'main' into upgrade-kaleido
emilykl Mar 4, 2025
2e9c8af
update test requirements
emilykl Mar 4, 2025
60bb748
simplify to_image
emilykl Mar 4, 2025
b87f752
use k.calc_fig() instead of k.write_fig() in pio.full_figure_for_deve…
emilykl Mar 6, 2025
e203623
merge main
emilykl Mar 7, 2025
8054331
merge main
emilykl Mar 11, 2025
1a195a7
add ci job to test with kaleido v1
emilykl Mar 11, 2025
577d3ca
remove -y option
emilykl Mar 11, 2025
89209ad
run test_kaleido instead of test_io
emilykl Mar 11, 2025
96bf9a0
re-add orca, add deprecation warnings for orca and kaleido-v0 (exact …
emilykl Mar 13, 2025
350dd48
error message for 'eps' with kaleido v1
emilykl Mar 20, 2025
08c1d4e
pin kaleido v1 (prerelease) in test requirements
emilykl Mar 20, 2025
8b47a0a
format
emilykl Mar 21, 2025
249cc9f
deprecation warning wording
emilykl Mar 24, 2025
ad9dbd9
fix if/else for when engine not specified
emilykl Mar 24, 2025
e75a5df
add flow and endpoint for installing chrome via plotly
emilykl Mar 25, 2025
a2b4f3c
add write_images and to_images functions (not yet using shared Kaleid…
emilykl Mar 25, 2025
2549299
format
emilykl Mar 25, 2025
ab3b700
fix test_image_renderer() test to work with both kaleido v0 and v1
emilykl Mar 27, 2025
de473e1
support pos args in to_images and write_images; rename plotly_install…
emilykl Mar 27, 2025
71696fe
mising pos args in write_images()
emilykl Mar 27, 2025
100b955
add tests for write_images() and to_images()
emilykl Mar 27, 2025
5541a79
add new API for setting image generation defaults
emilykl Mar 27, 2025
95a05db
format
emilykl Mar 27, 2025
0a73d0e
Merge branch 'main' into upgrade-kaleido
emilykl Mar 27, 2025
4d3dd56
install kaleido 1.0.0rc11 from PyPI
emilykl Mar 28, 2025
d871e74
remove extra import
emilykl Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
deprecation warning wording
emilykl committed Mar 24, 2025
commit 249cc9f1f559845dd18997b878a3d72b41cbb519
22 changes: 13 additions & 9 deletions plotly/io/_kaleido.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
import plotly
from plotly.io._utils import validate_coerce_fig_to_dict

ENGINE_SUPPORT_TIMELINE = "September 2025"

try:
import kaleido

@@ -95,7 +97,7 @@ def to_image(
# -------------
if engine is not None:
warnings.warn(
"The 'engine' parameter is deprecated and will be removed in a future version.",
f"DeprecationWarning: The 'engine' argument is deprecated. Kaleido will be the only supported engine after {ENGINE_SUPPORT_TIMELINE}.",
DeprecationWarning,
)
engine = "auto"
@@ -118,8 +120,8 @@ def to_image(

if engine == "orca":
warnings.warn(
"Support for the 'orca' engine is deprecated and will be removed in a future version. "
"Please use the 'kaleido' engine instead.",
f"Support for the orca engine is deprecated and will be removed after {ENGINE_SUPPORT_TIMELINE}. "
+ "Please install Kaleido (`pip install kaleido`) to use the Kaleido engine.",
DeprecationWarning,
)
# Fall back to legacy orca image export path
@@ -178,8 +180,7 @@ def to_image(
else:
# Kaleido v0
warnings.warn(
"Support for kaleido v0 is deprecated and will be removed in a future version. "
"Please upgrade to kaleido v1 by running `pip install kaleido>=1.0.0`.",
f"Support for Kaleido versions less than 1.0.0 is deprecated and will be removed after {ENGINE_SUPPORT_TIMELINE}. Please upgrade Kaleido to version 1.0.0 or greater (`pip install --upgrade kaleido`).",
DeprecationWarning,
)
img_bytes = scope.transform(
@@ -288,7 +289,9 @@ def write_image(

>>> import plotly.io as pio
>>> pio.write_image(fig, file_path, format='png')
""".format(file=file)
""".format(
file=file
)
)

# Request image
@@ -317,7 +320,9 @@ def write_image(
raise ValueError(
"""
The 'file' argument '{file}' is not a string, pathlib.Path object, or file descriptor.
""".format(file=file)
""".format(
file=file
)
)
else:
# We previously succeeded in interpreting `file` as a pathlib object.
@@ -380,8 +385,7 @@ def full_figure_for_development(fig, warn=True, as_dict=False):
else:
# Kaleido v0
warnings.warn(
"Support for kaleido v0 is deprecated and will be removed in a future version. "
"Please upgrade to kaleido v1 by running `pip install kaleido>=1.0.0`.",
f"Support for Kaleido versions less than 1.0.0 is deprecated and will be removed after {ENGINE_SUPPORT_TIMELINE}. Please upgrade Kaleido to version 1.0.0 or greater (`pip install --upgrade kaleido`).",
DeprecationWarning,
)
fig = json.loads(scope.transform(fig, format="json").decode("utf-8"))