Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bokeh's push_notebook is permanently dead in Colab — Google blocks
Jupyter Comms (bokeh#9302, colabtools#217). Detect Colab via
'google.colab' in sys.modules and take a separate render path:
- Render the gridplot to a self-contained HTML doc via
bokeh.embed.file_html with CDN resources.
- Wrap it in <iframe srcdoc="..."> so DOM lookups inside the
BokehJS bootstrap find their sibling JSON-data element (Colab's
output handling fragments inline scripts from sibling DOM,
which broke a flat-HTML attempt with a "Cannot read properties
of null (reading 'textContent') at embed_document" error).
- Display via IPython display(..., display_id=True) and update
the same handle on subsequent send() calls — update_display_data
is atomic, so the iframe is replaced cleanly with no flicker.
Also drops the notebook_type='colab' kwarg from output_notebook;
Bokeh 3.x removed that hook and raises RuntimeError if passed.
Modern Bokeh auto-detects Colab in plain output_notebook().
Includes examples/bokeh_colab.ipynb that installs livelossplot from
this branch on GitHub for in-Colab verification.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #109 (wow, I had lost hope on this one)