-
Notifications
You must be signed in to change notification settings - Fork 48
Add pass through kopts dict for kaleido args #316
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -33,17 +33,25 @@ async def calc_fig( | |||||||
opts=None, | ||||||||
*, | ||||||||
topojson=None, | ||||||||
kopts=None, | ||||||||
): | ||||||||
""" | ||||||||
Return binary for plotly figure. | ||||||||
|
||||||||
A convenience wrapper for `Kaleido.calc_fig()` which starts a `Kaleido` and | ||||||||
executes the `calc_fig()`. | ||||||||
It takes an additional argument, `kopts`, a dictionary of arguments to pass | ||||||||
to the kaleido process. See the `kaleido.Kaleido` docs. However, | ||||||||
`calc_fig()` will never use more than one processor, so any `n` value will | ||||||||
be overridden. | ||||||||
|
||||||||
|
||||||||
See documentation for `Kaleido.calc_fig()`. | ||||||||
|
||||||||
""" | ||||||||
async with Kaleido(n=1) as k: | ||||||||
kopts = kopts or {} | ||||||||
kopts["n"] = 1 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't override user-provided value for
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. calc_figs can't iterate, so it doesn't make sense for n>1 (its mentioned in the docs, that any value of n will be overwritten to 1) |
||||||||
async with Kaleido(**kopts) as k: | ||||||||
return await k.calc_fig( | ||||||||
fig, | ||||||||
path=path, | ||||||||
|
@@ -60,20 +68,21 @@ async def write_fig( # noqa: PLR0913 (too many args, complexity) | |||||||
topojson=None, | ||||||||
error_log=None, | ||||||||
profiler=None, | ||||||||
n=1, | ||||||||
kopts=None, | ||||||||
): | ||||||||
""" | ||||||||
Write a plotly figure(s) to a file. | ||||||||
|
||||||||
A convenience wrapper for `Kaleido.write_fig()` which starts a `Kaleido` and | ||||||||
executes the `write_fig()`. | ||||||||
It takes one additional argument, `n`, which can be used to set the number | ||||||||
of processes. | ||||||||
It takes an additional argument, `kopts`, a dictionary of arguments to pass | ||||||||
to the kaleido process. See the `kaleido.Kaleido` docs. | ||||||||
|
||||||||
|
||||||||
See documentation for `Kaleido.write_fig()`. | ||||||||
See documentation for `Kaleido.write_fig()` for the other arguments. | ||||||||
|
||||||||
""" | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to do a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah
|
||||||||
async with Kaleido(n=n) as k: | ||||||||
async with Kaleido(**(kopts or {})) as k: | ||||||||
await k.write_fig( | ||||||||
fig, | ||||||||
path=path, | ||||||||
|
@@ -89,20 +98,21 @@ async def write_fig_from_object( | |||||||
*, | ||||||||
error_log=None, | ||||||||
profiler=None, | ||||||||
n=1, | ||||||||
kopts=None, | ||||||||
): | ||||||||
""" | ||||||||
Write a plotly figure(s) to a file. | ||||||||
|
||||||||
A convenience wrapper for `Kaleido.write_fig_from_object()` which starts a | ||||||||
`Kaleido` and executes the `write_fig_from_object()` | ||||||||
It takes one additional argument, `n`, which can be used to set the number | ||||||||
of processes. | ||||||||
It takes an additional argument, `kopts`, a dictionary of arguments to pass | ||||||||
to the kaleido process. See the `kaleido.Kaleido` docs. | ||||||||
|
||||||||
See documentation for `Kaleido.write_fig_from_object()`. | ||||||||
See documentation for `Kaleido.write_fig_from_object()` for the other | ||||||||
arguments. | ||||||||
|
||||||||
""" | ||||||||
async with Kaleido(n=n) as k: | ||||||||
async with Kaleido(**(kopts or {})) as k: | ||||||||
await k.write_fig_from_object( | ||||||||
generator, | ||||||||
error_log=error_log, | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add
kopts
argument tocalc_fig
as well for consistencyUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i want to move towards using BytesIO as a return for
write_image
instead ofcalc_fig
which is sort of hackey, but added thekopts
option anyway