Skip to content

Commit 5ee484f

Browse files
committed
Add pass through kopts dict for kaleido args
1 parent 9eafaea commit 5ee484f

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

src/py/kaleido/__init__.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,23 @@ async def write_fig( # noqa: PLR0913 (too many args, complexity)
6161
error_log=None,
6262
profiler=None,
6363
n=1,
64+
kopts=None,
6465
):
6566
"""
6667
Write a plotly figure(s) to a file.
6768
6869
A convenience wrapper for `Kaleido.write_fig()` which starts a `Kaleido` and
6970
executes the `write_fig()`.
70-
It takes one additional argument, `n`, which can be used to set the number
71-
of processes.
71+
It takes an additional argument, `kopts`, a dictionary of arguments to pass
72+
to the kaleido process. See the `kaleido.Kaleido` docs.
7273
73-
See documentation for `Kaleido.write_fig()`.
74+
75+
See documentation for `Kaleido.write_fig()` for the other arguments.
7476
7577
"""
76-
async with Kaleido(n=n) as k:
78+
if "n" not in kopts:
79+
kopts["n"] = n
80+
async with Kaleido(**kopts) as k:
7781
await k.write_fig(
7882
fig,
7983
path=path,
@@ -90,19 +94,23 @@ async def write_fig_from_object(
9094
error_log=None,
9195
profiler=None,
9296
n=1,
97+
kopts=None,
9398
):
9499
"""
95100
Write a plotly figure(s) to a file.
96101
97102
A convenience wrapper for `Kaleido.write_fig_from_object()` which starts a
98103
`Kaleido` and executes the `write_fig_from_object()`
99-
It takes one additional argument, `n`, which can be used to set the number
100-
of processes.
104+
It takes an additional argument, `kopts`, a dictionary of arguments to pass
105+
to the kaleido process. See the `kaleido.Kaleido` docs.
101106
102-
See documentation for `Kaleido.write_fig_from_object()`.
107+
See documentation for `Kaleido.write_fig_from_object()` for the other
108+
arguments.
103109
104110
"""
105-
async with Kaleido(n=n) as k:
111+
if "n" not in kopts:
112+
kopts["n"] = n
113+
async with Kaleido(**kopts) as k:
106114
await k.write_fig_from_object(
107115
generator,
108116
error_log=error_log,

0 commit comments

Comments
 (0)