docs: import panel in Flask + Bokeh deployment example#6881
Merged
Conversation
The Combining Bokeh Application and Flask Application example failed with `bokeh.core.serialization.DeserializationError: can't resolve type 'panel.models.browser.BrowserInfo'` because `panel.models.browser` isn't loaded by the bokeh imports in flaskApp.py and so the panel- created session can't be deserialized by `pull_session`. philippjfr noted in holoviz#6041 that the docs example should include `import panel`, which loads the panel models with bokeh so they resolve during deserialization. Fixes holoviz#6041
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6881 +/- ##
=======================================
Coverage 89.22% 89.22%
=======================================
Files 340 340
Lines 73969 73969
=======================================
Hits 65999 65999
Misses 7970 7970 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Thank you for the PR |
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.
Description
The Combining Bokeh Application and Flask Application example in the Deploying Bokeh Apps user guide gives a runnable
flaskApp.pythat fails the moment Panel renders a HoloViewsDynamicMap:pn.serve(...)adds Panel-specific models (e.g.panel.models.browser.BrowserInfo) to the document, butflaskApp.pyonly imports frombokeh.client/bokeh.embed/flask, so whenpull_session(...)deserializes the session those types aren't registered with bokeh and the request 500s.In #6041 philippjfr identified two fixes, including that "the HoloViews docs should be updated to include
import panel." Importingpanelregisters its bokeh model classes sopull_session/server_sessioncan deserialize them on the Flask side. This PR adds that singleimport panelline to theflaskApp.pyblock inexamples/user_guide/Deploying_Bokeh_Apps.ipynb, with a short comment explaining why the import is there even though the symbol isn't otherwise referenced (so a linter or a curious reader doesn't strip it).Fixes #6041
How Has This Been Tested?
This is a single import-line addition to a Python code block inside a markdown cell of a
.ipynbthat the docs build skips (:skip_execute: Trueindoc/user_guide/Deploying_Bokeh_Apps.rst), so the change has no runtime effect onnbsite/Sphinx output beyond rendering the extra line. I verified:python -c "import json; json.load(open('examples/user_guide/Deploying_Bokeh_Apps.ipynb'))"still parses the notebook cleanly.flaskApp.pymarkdown code block and does not touch any other cell, executed code, or metadata.I did not stand up the full Flask + Bokeh + Panel stack locally to re-run the original repro; the maintainer comment on #6041 already established that
import panelis the docs-side fix. If you'd prefer the docs to also includeimport panel.models.browser(the full workaround philippjfr suggested for users hitting the error today), happy to add it in a fixup commit.AI Disclosure
Tools and Models: Claude Code + Opus 4.7. Used to draft the one-line docs change and this PR body; I reviewed the diff and the notebook JSON before pushing.
Checklist