Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 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
b3e8d36
add [kaleido] install extra to pyproject.toml to help with installing…
emilykl Mar 31, 2025
ef5f520
fix deprecation warnings
emilykl Mar 31, 2025
611e2e4
Merge branch 'main' into upgrade-kaleido
emilykl Mar 31, 2025
c92a1ee
small updates to deprecation warning text
emilykl Mar 31, 2025
b56d5ec
Merge branch 'upgrade-kaleido' of https://github.com/plotly/plotly.py…
emilykl Mar 31, 2025
c01cb8a
add missing changelog entries
emilykl Mar 31, 2025
bcd40f3
update changelog for 6.1.0b0
emilykl Mar 31, 2025
54985b8
update pyproject.toml for 6.1.0b0
emilykl Mar 31, 2025
b4af0d5
Merge pull request #5121 from plotly/release-6.1.0b0
emilykl Mar 31, 2025
0f61cc3
remove to_images tests
emilykl Apr 13, 2025
fe12aec
remove to_images function
emilykl Apr 13, 2025
692842f
refactor write_images to use kaleido write_fig function (WIP)
emilykl Apr 14, 2025
aac9c20
refactor write_images() to use kaleido.write_fig_from_object_sync()
emilykl Apr 14, 2025
ad57031
update kaleido tests
emilykl Apr 14, 2025
b9e5f7a
Merge branch 'main' into upgrade-kaleido
emilykl Apr 14, 2025
720ada5
add and fix type hints
emilykl Apr 14, 2025
53d486a
add mathjax and topojson config options
emilykl Apr 15, 2025
c990736
format
emilykl Apr 15, 2025
96bb17a
fix a few bugs with setting topojson default
emilykl Apr 24, 2025
f736f4c
remove 'import choreographer' and fix SyntaxWarning
emilykl Apr 24, 2025
aca1620
update kaleido rc version for tests
emilykl Apr 24, 2025
564aa51
clean up deprecation messages, fix bug with passing mathjax
emilykl Apr 28, 2025
2b45f47
add --path argument for plotly_get_chrome command
emilykl Apr 28, 2025
691fce6
format
emilykl Apr 28, 2025
0799bf5
merge main
emilykl Apr 28, 2025
651eafd
print exe path after installing Chrome
emilykl Apr 29, 2025
0413341
format
emilykl Apr 29, 2025
0c1b1c1
format
emilykl Apr 29, 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
fix a few bugs with setting topojson default
  • Loading branch information
emilykl committed Apr 24, 2025
commit 96bb17a4f43ff0ce3d824717d9a128898cd6ef37
4 changes: 2 additions & 2 deletions plotly/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ._html import to_html, write_html
from ._renderers import renderers, show
from . import base_renderers
from ._defaults import defaults
from ._kaleido import defaults

__all__ = [
"to_image",
Expand Down Expand Up @@ -57,7 +57,7 @@
"._html.write_html",
"._renderers.renderers",
"._renderers.show",
"._defaults.defaults",
"._kaleido.defaults",
],
)

Expand Down
45 changes: 31 additions & 14 deletions plotly/io/_kaleido.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import plotly
from plotly.io._utils import validate_coerce_fig_to_dict, broadcast_args_to_dicts
from plotly.io import defaults
from plotly.io._defaults import defaults

ENGINE_SUPPORT_TIMELINE = "September 2025"

Expand Down Expand Up @@ -98,35 +98,54 @@ def __setattr__(self, name, value):
DeprecationWarning,
stacklevel=2,
)
setattr(defaults, name, value)
super(PlotlyScopeWithDeprecationWarnings, self).__setattr__(name, value)
super().__setattr__(name, value)

def __getattr__(self, name):
if name in defaults.__dict__:
if hasattr(defaults, name):
warnings.warn(
kaleido_scope_default_warning_func(name),
DeprecationWarning,
stacklevel=2,
)
return super(PlotlyScopeWithDeprecationWarnings, self).__getattr__(name)
return super().__getattr__(name)

# Ensure the new method of setting defaults is backwards compatible with Kaleido v0
class DefaultsBackwardsCompatible(defaults.__class__):
def __init__(self, scope):
self._scope = scope
super().__init__()

def __setattr__(self, name, value):
if not name == "_scope":
if (
hasattr(self._scope, name)
and getattr(self._scope, name) != value
):
setattr(self._scope, name, value)
super().__setattr__(name, value)

scope = PlotlyScopeWithDeprecationWarnings()
defaults = DefaultsBackwardsCompatible(scope)
# Compute absolute path to the 'plotly/package_data/' directory
root_dir = os.path.dirname(os.path.abspath(plotly.__file__))
package_dir = os.path.join(root_dir, "package_data")
scope.plotlyjs = os.path.join(package_dir, "plotly.min.js")
if scope.mathjax is None:
scope.mathjax = (
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"
)
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", message=".*scope\.mathjax.*", category=DeprecationWarning
)
scope.mathjax = (
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"
)
else:
# Kaleido v1
import kaleido

# Show a deprecation warning if the old method of setting defaults is used
class DefaultsDeprecationWarning:
def __getattr__(self, name):
if name in defaults.__dict__:
if hasattr(defaults, name):
warnings.warn(
kaleido_scope_default_warning_func(name),
DeprecationWarning,
Expand All @@ -137,7 +156,7 @@ def __getattr__(self, name):
raise AttributeError(bad_attribute_error_msg_func(name))

def __setattr__(self, name, value):
if name in defaults.__dict__:
if hasattr(defaults, name):
warnings.warn(
kaleido_scope_default_warning_func(name),
DeprecationWarning,
Expand Down Expand Up @@ -344,9 +363,7 @@ def to_image(
height=height or defaults.default_height,
scale=scale or defaults.default_scale,
),
topojson=Path(defaults.topojson).as_uri()
if defaults.topojson
else None,
topojson=defaults.topojson,
# mathjax=Path(defaults.mathjax).as_uri() if defaults.mathjax else None,
)
except choreographer.errors.ChromeNotFoundError:
Expand Down Expand Up @@ -615,7 +632,7 @@ def write_images(
height=d["height"] or defaults.default_height,
scale=d["scale"] or defaults.default_scale,
),
"topojson": Path(defaults.topojson).as_uri() if defaults.topojson else None,
"topojson": defaults.topojson,
# "mathjax": Path(defaults.mathjax).as_uri() if defaults.mathjax else None,
}
for d in arg_dicts
Expand Down