Skip to content

v6.1.0 breaks fig.write_image() #5187

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

Open
petrchmelar opened this issue May 16, 2025 · 2 comments
Open

v6.1.0 breaks fig.write_image() #5187

petrchmelar opened this issue May 16, 2025 · 2 comments

Comments

@petrchmelar
Copy link

petrchmelar commented May 16, 2025

Hi, it seems that setting the ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS = False broke the write_image() method.

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)

https://github.com/plotly/plotly.py/pull/5177/files#diff-e30d1d28e90c51821f0eeed0db68656f4317c0754deaec93c3365b8a93b4caefR14

@petrchmelar petrchmelar changed the title V6.1.0 breaks fig.write_image() v6.1.0 breaks fig.write_image() May 16, 2025
@ErikPGJ
Copy link

ErikPGJ commented May 16, 2025

I see this problem too (it broke CI tests). I am not familiar with the source code but superficially, it works if one removes one level of indentation for return pio.write_image(self, *args, **kwargs).

@Remi-Gau
Copy link

regression test

import plotly.graph_objects as go
import numpy as np

def test_write_image(tmp_path):

    np.random.seed(1)

    N = 100
    x = np.random.rand(N)
    y = np.random.rand(N)

    fig = go.Figure()
    fig.add_trace(go.Scatter(
        x=x,
        y=y,
        mode="markers",
    ))

    fig.write_image(tmp_path / "fig1.png")

    assert (tmp_path /"fig1.png").exists()
E       AssertionError: assert False
E        +  where False = exists()
E        +    where exists = (PosixPath('/tmp/pytest-of-remi-gau/pytest-9/test_write_image0') / 'fig1.png').exists

Version tested

plotly kaleido test
6.0.1 0.2.1
6.1.0 0.2.1
6.1.0 1.0.0rc13

Also note that kaleido extra dependency

kaleido = ["kaleido==1.0.0rc13"]

will only work if the use ask for --prerelease.

Without this, pip install effectively falls back to 6.0.1.

$ pip install 'plotly[kaleido]' 

Resolved 3 packages in 6ms
Installed 3 packages in 291ms
 + narwhals==1.39.1
 + packaging==25.0
 + plotly==6.0.1
warning: The package `plotly==6.0.1` does not have an extra named `kaleido`
$ pip install --prerelease 'plotly[kaleido]'

Resolved 8 packages in 10ms
Installed 6 packages in 189ms
 + choreographer==1.0.7
 + kaleido==1.0.0rc13
 + logistro==1.1.0
 + orjson==3.10.18
 + plotly==6.1.0
 + simplejson==3.20.1

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

No branches or pull requests

3 participants