Skip to content

Andrew/fix encoder - #406

Merged
ayjayt merged 13 commits into
masterfrom
andrew/fix-encoder
Oct 6, 2025
Merged

ayjayt merged 13 commits into
masterfrom
andrew/fix-encoder

Conversation

@ayjayt

@ayjayt ayjayt commented Sep 16, 2025 •

Copy link
Copy Markdown
Collaborator

Depends on https://github.com/plotly/choreographer/pull/249/files

Kaleido will now see if plotly is available to use its JSONEncoder if so.

@ayjayt
ayjayt marked this pull request as ready for review September 17, 2025 19:57
Comment thread src/py/kaleido/kaleido.py Outdated
Comment on lines +31 to +38
try:
from choreographer import channels
from plotly.utils import PlotlyJSONEncoder

channels.register_custom_encoder(PlotlyJSONEncoder)
_logger.debug("Successfully registered PlotlyJSONEncoder.")
except ImportError:
_logger.debug("Couldn't import plotly- skipping.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Separate the choreographer import into a separate try/except so that the logger message can be more accurate

@ayjayt ayjayt Sep 18, 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 changed the log to include the error, I kept the imports together since we can bail out of importing channels if there is no Plotly. Let me know if that's cool.

Comment thread src/py/CHANGELOG.txt Outdated
@@ -1,3 +1,6 @@
v1.2.0
- Add plotly dependency: use its encoder instead of our custom.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

update changelog entry (Plotly not a dependency)

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.

done

@emilykl

emilykl commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

@ayjayt Are there tests for this feature? Maybe using the figure @daexs created that raised this issue in the first place?

@ayjayt

ayjayt commented Sep 18, 2025

Copy link
Copy Markdown
Collaborator Author

@ayjayt Are there tests for this feature? Maybe using the figure @daexs created that raised this issue in the first place?

You can see the start of a new concept for integration tests where I use pickled figures instead of JSON mocks to provoke JSON encoding errors. That's where this type of test belongs, I believe, because our unit tests shouldn't lock down the choreographer or _plotly_utils behavior. Happy to chat about it or write a README if you prefer. Don't want to add that feature to this pr though, so I just created the structure from it and in the next PR I'll execute the tests, since that is what I'm working on anyway.

@emilykl emilykl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should have a unit test for this behavior, otherwise LGTM 🚀

@gvwilson gvwilson added fix fixes something broken P1 needs immediate attention labels Sep 26, 2025
@ayjayt
ayjayt merged commit 5385b60 into master Oct 6, 2025
4 checks passed
@ayjayt
ayjayt deleted the andrew/fix-encoder branch October 6, 2025 18:13

This branch was previously deployed

1 inactive deployment
testpypi — d93391eb Deployed Oct 6, 2025 by ayjayt via Upload release to TestPyPI #44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix fixes something broken P1 needs immediate attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants