Skip to content

Commit f2f01be

Browse files
committed
fix intermittent Bokeh widget render via output_notebook(resources=INLINE)
The diachronic-analysis plot uses RadioButtonGroup/Switch from bokeh.models.widgets. With the default CDN autoload, Bokeh fires embed_document as soon as window.Bokeh is defined (after bokeh.min.js parses) — so on slow loads bokeh-widgets.min.js hasn't registered RadioButtonGroup yet and the figure fails with "could not resolve type 'RadioButtonGroup'". Switching to INLINE resources embeds the full BokehJS bundle synchronously in one script tag, eliminating the race.
1 parent ff627f6 commit f2f01be

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

corpus_analysis/corpus-analysis_diachronic-analysis.ipynb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,7 @@
8080
]
8181
},
8282
"outputs": [],
83-
"source": [
84-
"import re\n",
85-
"import requests\n",
86-
"from pathlib import Path\n",
87-
"import pandas as pd\n",
88-
"\n",
89-
"# for interactivity in jupyter books\n",
90-
"#from bokeh.application import Application\n",
91-
"#from bokeh.application.handlers import FunctionHandler\n",
92-
"from bokeh.io import output_notebook, show\n",
93-
"from bokeh.plotting import figure\n",
94-
"from bokeh.layouts import column, row\n",
95-
"from bokeh.models import ColumnDataSource, CustomJS, TextInput, Div, RadioButtonGroup, Switch\n",
96-
"# Ensure Bokeh output is displayed in the notebook\n",
97-
"output_notebook()"
98-
]
83+
"source": "import re\nimport requests\nfrom pathlib import Path\nimport pandas as pd\n\n# for interactivity in jupyter books\n#from bokeh.application import Application\n#from bokeh.application.handlers import FunctionHandler\nfrom bokeh.io import output_notebook, show\nfrom bokeh.plotting import figure\nfrom bokeh.layouts import column, row\nfrom bokeh.models import ColumnDataSource, CustomJS, TextInput, Div, RadioButtonGroup, Switch\nfrom bokeh.resources import INLINE\n# Ensure Bokeh output is displayed in the notebook.\n# resources=INLINE embeds BokehJS (incl. the widgets bundle) directly into\n# the page so RadioButtonGroup/Switch are registered before embed_item runs;\n# the default CDN autoload is racy in static Jupyter Book HTML.\noutput_notebook(resources=INLINE)"
9984
},
10085
{
10186
"cell_type": "markdown",
@@ -813,4 +798,4 @@
813798
},
814799
"nbformat": 4,
815800
"nbformat_minor": 5
816-
}
801+
}

0 commit comments

Comments
 (0)