-
Notifications
You must be signed in to change notification settings - Fork 52
Andrew/fix encoder #406
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
Andrew/fix encoder #406
Conversation
src/py/kaleido/kaleido.py
Outdated
| 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.") |
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.
Separate the choreographer import into a separate try/except so that the logger message can be more accurate
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 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.
src/py/CHANGELOG.txt
Outdated
| @@ -1,3 +1,6 @@ | |||
| v1.2.0 | |||
| - Add plotly dependency: use its encoder instead of our custom. | |||
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.
update changelog entry (Plotly not a dependency)
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.
done
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
left a comment
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 have a unit test for this behavior, otherwise LGTM 🚀
Depends on https://github.com/plotly/choreographer/pull/249/filesKaleido will now see if plotly is available to use its JSONEncoder if so.