Skip to content

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

Merged
merged 5 commits into from
Apr 16, 2025
Merged

Conversation

ayjayt
Copy link
Collaborator

@ayjayt ayjayt commented Apr 15, 2025

No description provided.

@ayjayt ayjayt requested a review from emilykl April 15, 2025 18:39

"""
async with Kaleido(n=n) as k:
if "n" not in kopts:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you wanting to keep the separate n argument for backwards compatibility? Or could it be removed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue for removing it just to avoid confusion (since it's not obvious which way of passing n takes precedence)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i mean, i know technically we're in a release candidate but i didn't want to change the API

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to remove it TBH but if not, maybe add a DeprecationWarning so it can be removed in a future release?


See documentation for `Kaleido.write_fig()`.

See documentation for `Kaleido.write_fig()` for the other arguments.

"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to do a kopts = kopts or {} here, right? Otherwise the dict operations will fail if kopts is None.

Copy link
Collaborator Author

@ayjayt ayjayt Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

In [2]: foo(**None)
─────────────────────────────────────────
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
────▶ 1 foo(**None)

TypeError: __main__.foo() argument after ** must be a mapping, not NoneType

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add kopts argument to calc_fig as well for consistency

Copy link
Collaborator Author

@ayjayt ayjayt Apr 16, 2025

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 of calc_fig which is sort of hackey, but added the kopts option anyway

@ayjayt ayjayt requested a review from emilykl April 16, 2025 21:16

See documentation for `Kaleido.calc_fig()`.

"""
async with Kaleido(n=1) as k:
kopts = kopts or {}
kopts["n"] = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't override user-provided value for n

Suggested change
kopts["n"] = 1
if "n" not in kopts:
kopts["n"] = 1

Copy link
Collaborator Author

@ayjayt ayjayt Apr 16, 2025

Choose a reason for hiding this comment

The 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)

Copy link
Collaborator

@emilykl emilykl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 🚀

@ayjayt ayjayt merged commit 154cd0d into master Apr 16, 2025
4 checks passed
@ayjayt ayjayt deleted the andrew/add_kopts branch April 16, 2025 22:42
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

Successfully merging this pull request may close these issues.

2 participants