Skip to content

Disable Kaleido deprecation warnings #5177

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

Merged
merged 3 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
94 changes: 49 additions & 45 deletions plotly/basedatatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3740,29 +3740,29 @@ def to_image(self, *args, **kwargs):
- 'webp'
- 'svg'
- 'pdf'
- 'eps' (deprecated) (Requires the poppler library to be installed)
- 'eps' (Kaleido v0.* only) (Requires the poppler library to be installed)

If not specified, will default to:
- `plotly.io.defaults.default_format` if engine is "kaleido"
- `plotly.io.orca.config.default_format` if engine is "orca" (deprecated)
- `plotly.io.defaults.default_format` or `plotly.io.kaleido.scope.default_format` if engine is "kaleido"
- `plotly.io.orca.config.default_format` if engine is "orca"

width: int or None
The width of the exported image in layout pixels. If the `scale`
property is 1.0, this will also be the width of the exported image
in physical pixels.

If not specified, will default to:
- `plotly.io.defaults.default_width` if engine is "kaleido"
- `plotly.io.orca.config.default_width` if engine is "orca" (deprecated)
- `plotly.io.defaults.default_width` or `plotly.io.kaleido.scope.default_width` if engine is "kaleido"
- `plotly.io.orca.config.default_width` if engine is "orca"

height: int or None
The height of the exported image in layout pixels. If the `scale`
property is 1.0, this will also be the height of the exported image
in physical pixels.

If not specified, will default to:
- `plotly.io.defaults.default_height` if engine is "kaleido"
- `plotly.io.orca.config.default_height` if engine is "orca" (deprecated)
- `plotly.io.defaults.default_height` or `plotly.io.kaleido.scope.default_height` if engine is "kaleido"
- `plotly.io.orca.config.default_height` if engine is "orca"

scale: int or float or None
The scale factor to use when exporting the figure. A scale factor
Expand All @@ -3771,14 +3771,14 @@ def to_image(self, *args, **kwargs):
less than 1.0 will decrease the image resolution.

If not specified, will default to:
- `plotly.io.defaults.default_scale` if engine is "kaliedo"
- `plotly.io.orca.config.default_scale` if engine is "orca" (deprecated)
- `plotly.io.defaults.default_scale` or `plotly.io.kaleido.scope.default_scale` if engine is "kaliedo"
- `plotly.io.orca.config.default_scale` if engine is "orca"

validate: bool
True if the figure should be validated before being converted to
an image, False otherwise.

engine (deprecated): str
engine: str
Image export engine to use. This parameter is deprecated and Orca engine support will be
dropped in the next major Plotly version. Until then, the following values are supported:
- "kaleido": Use Kaleido for image export
Expand All @@ -3794,23 +3794,25 @@ def to_image(self, *args, **kwargs):
from plotly.io.kaleido import (
kaleido_available,
kaleido_major,
ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS,
KALEIDO_DEPRECATION_MSG,
ORCA_DEPRECATION_MSG,
ENGINE_PARAM_DEPRECATION_MSG,
)

if (
kwargs.get("engine", None) in {None, "auto", "kaleido"}
and kaleido_available()
and kaleido_major() < 1
):
warnings.warn(KALEIDO_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
if kwargs.get("engine", None) == "orca":
warnings.warn(ORCA_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
if kwargs.get("engine", None):
warnings.warn(
ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
)
if ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS:
if (
kwargs.get("engine", None) in {None, "auto", "kaleido"}
and kaleido_available()
and kaleido_major() < 1
):
warnings.warn(KALEIDO_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
if kwargs.get("engine", None) == "orca":
warnings.warn(ORCA_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
if kwargs.get("engine", None):
warnings.warn(
ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
)

return pio.to_image(self, *args, **kwargs)

Expand All @@ -3832,31 +3834,31 @@ def write_image(self, *args, **kwargs):
- 'webp'
- 'svg'
- 'pdf'
- 'eps' (deprecated) (Requires the poppler library to be installed)
- 'eps' (Kaleido v0.* only) (Requires the poppler library to be installed)

If not specified and `file` is a string then this will default to the
file extension. If not specified and `file` is not a string then this
will default to:
- `plotly.io.defaults.default_format` if engine is "kaleido"
- `plotly.io.orca.config.default_format` if engine is "orca" (deprecated)
- `plotly.io.defaults.default_format` or `plotly.io.kaleido.scope.default_format` if engine is "kaleido"
- `plotly.io.orca.config.default_format` if engine is "orca"

width: int or None
The width of the exported image in layout pixels. If the `scale`
property is 1.0, this will also be the width of the exported image
in physical pixels.

If not specified, will default to:
- `plotly.io.defaults.default_width` if engine is "kaleido"
- `plotly.io.orca.config.default_width` if engine is "orca" (deprecated)
- `plotly.io.defaults.default_width` or `plotly.io.kaleido.scope.default_width` if engine is "kaleido"
- `plotly.io.orca.config.default_width` if engine is "orca"

height: int or None
The height of the exported image in layout pixels. If the `scale`
property is 1.0, this will also be the height of the exported image
in physical pixels.

If not specified, will default to:
- `plotly.io.defaults.default_height` if engine is "kaleido"
- `plotly.io.orca.config.default_height` if engine is "orca" (deprecated)
- `plotly.io.defaults.default_height` or `plotly.io.kaleido.scope.default_height` if engine is "kaleido"
- `plotly.io.orca.config.default_height` if engine is "orca"

scale: int or float or None
The scale factor to use when exporting the figure. A scale factor
Expand All @@ -3865,14 +3867,14 @@ def write_image(self, *args, **kwargs):
less than 1.0 will decrease the image resolution.

If not specified, will default to:
- `plotly.io.defaults.default_scale` if engine is "kaleido"
- `plotly.io.orca.config.default_scale` if engine is "orca" (deprecated)
- `plotly.io.defaults.default_scale` or `plotly.io.kaleido.scope.default_scale` if engine is "kaleido"
- `plotly.io.orca.config.default_scale` if engine is "orca"

validate: bool
True if the figure should be validated before being converted to
an image, False otherwise.

engine (deprecated): str
engine: str
Image export engine to use. This parameter is deprecated and Orca engine support will be
dropped in the next major Plotly version. Until then, the following values are supported:
- "kaleido": Use Kaleido for image export
Expand All @@ -3887,24 +3889,26 @@ def write_image(self, *args, **kwargs):
from plotly.io.kaleido import (
kaleido_available,
kaleido_major,
ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS,
KALEIDO_DEPRECATION_MSG,
ORCA_DEPRECATION_MSG,
ENGINE_PARAM_DEPRECATION_MSG,
)

if (
kwargs.get("engine", None) in {None, "auto", "kaleido"}
and kaleido_available()
and kaleido_major() < 1
):
warnings.warn(KALEIDO_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
if kwargs.get("engine", None) == "orca":
warnings.warn(ORCA_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
if kwargs.get("engine", None):
warnings.warn(
ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
)
return pio.write_image(self, *args, **kwargs)
if ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS:
if (
kwargs.get("engine", None) in {None, "auto", "kaleido"}
and kaleido_available()
and kaleido_major() < 1
):
warnings.warn(KALEIDO_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
if kwargs.get("engine", None) == "orca":
warnings.warn(ORCA_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
if kwargs.get("engine", None):
warnings.warn(
ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
)
return pio.write_image(self, *args, **kwargs)

# Static helpers
# --------------
Expand Down
Loading