Skip to content

Conversation

@ayjayt
Copy link
Collaborator

@ayjayt ayjayt commented Sep 16, 2025

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

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

Copy link
Collaborator Author

@ayjayt ayjayt Sep 18, 2025

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.

@@ -1,3 +1,6 @@
v1.2.0
- Add plotly dependency: use its encoder instead of our custom.
Copy link
Collaborator

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
Collaborator Author

Choose a reason for hiding this comment

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

done

@emilykl
Copy link
Collaborator

emilykl commented Sep 17, 2025

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

@ayjayt
Copy link
Collaborator Author

ayjayt commented Sep 18, 2025

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

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.

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

4 participants