Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add pass through kopts dict for kaleido args - #316

#316
Merged
ayjayt merged 5 commits into
masterplotly/Kaleido:masterfrom
andrew/add_koptsplotly/Kaleido:andrew/add_koptsCopy head branch name to clipboard
Apr 16, 2025
Merged

Add pass through kopts dict for kaleido args#316
ayjayt merged 5 commits into
masterplotly/Kaleido:masterfrom
andrew/add_koptsplotly/Kaleido:andrew/add_koptsCopy head branch name to clipboard

Conversation

@ayjayt

@ayjayt ayjayt commented Apr 15, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@ayjayt
ayjayt requested a review from emilykl April 15, 2025 18:39
Comment thread src/py/kaleido/__init__.py Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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()` for the other arguments.

"""

Copy link
Copy Markdown
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.

@ayjayt ayjayt Apr 16, 2025

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
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

@ayjayt ayjayt Apr 16, 2025

Copy link
Copy Markdown
Collaborator Author

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
"""
async with Kaleido(n=1) as k:
kopts = kopts or {}
kopts["n"] = 1

Copy link
Copy Markdown
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

@ayjayt ayjayt Apr 16, 2025

Copy link
Copy Markdown
Collaborator Author

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)

@emilykl emilykl left a comment

Copy link
Copy Markdown
Collaborator

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
@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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.