Set the 'colab' renderer only for Colab web notebooks#5473
Set the 'colab' renderer only for Colab web notebooks#5473kevineger wants to merge 3 commits intoplotly:mainfrom
Conversation
|
Hey @robertclaus and @camdecoster - mind taking a look or re-assigning? Let me know if any further action's needed on my end to move this along. Thanks and sorry for the nag! |
|
@kevineger could you give me some instructions for how to test this? I'm not familiar with the Colab extension. |
@camdecoster you could package this up and run a local Colab runtime (docs). |
The current implementation detects if the `google.colab` module is available. This has a couple problems: 1. Anyone can install that library, outside of Colab. 2. The recently launched [Colab VS Code extension](https://marketplace.visualstudio.com/items?itemName=Google.colab) does not work with that web-based renderer. Snapping to the conventions used for the other notebooks/renderers (e.g. Kaggle, Azure), this change now looks for the presence of the `COLAB_NOTEBOOK_ID` environment variable. I'm an engineer on Colab and have verified that we set this on kernel init for all notebooks accessed through our web app (https://colab.research.google.com/). More context in plotly#5471.
There was a problem hiding this comment.
@kevineger I verified your changes work for setting the renderer when the COLAB_NOTEBOOK_ID env var is present. Before this gets merged, could you please add a test in tests/test_io/test_renderers.py? After that's done, could you tag me in a comment?
EDIT: Could you also please add a changelog entry?
|
Done and done @camdecoster ✔️ Let me know if there's a better way to test than what I did. |
Full context in #5471.
The current implementation detects if the
google.colabmodule is available. This has a couple problems:Snapping to the conventions used for the other notebooks/renderers (e.g. Kaggle, Azure), this change now looks for the presence of the
COLAB_NOTEBOOK_IDenvironment variable. I'm an engineer on Colab and have verified that we set this on kernel init for all notebooks accessed through our web app (https://colab.research.google.com/).Code PR
plotly.graph_objects, my modifications concern the code generator and not the generated files.