bokeh: Multiple output_file in a single process can fail when models are shared
I have 2 anaconda environments in Windows 7:
- env1 has jupyter lab 0.32 and bokeh 0.12.16,
- env2 has jupyter lab 2.0.1 and bokeh 2.0.0.
In a jupyter notebook, I have 2 cells of code:
Cell 1
source1 = ColumnDataSource(fertility_df[fertility_df['Continent']=='ASI'])
p1 = figure(x_axis_label='fertility (children per woman)', y_axis_label='female literacy (% population)')
p1.circle('fertility', 'female literacy', source=source1)
source2 = ColumnDataSource(fertility_df[fertility_df['Continent']=='EUR'])
p2 = figure(x_axis_label='fertility (children per woman)', y_axis_label='female literacy (% population)')
p2.circle('fertility', 'female literacy', source=source2)
source3 = ColumnDataSource(fertility_df[fertility_df['Continent']=='AF'])
p3 = figure(x_axis_label='fertility (children per woman)', y_axis_label='female literacy (% population)')
p3.circle('fertility', 'female literacy', source=source3)
source4 = ColumnDataSource(fertility_df[fertility_df['Continent']=='LAT'])
p4 = figure(x_axis_label='fertility (children per woman)', y_axis_label='female literacy (% population)')
p4.circle('fertility', 'female literacy', source=source4)
row1 = [p1, p2]
row2 = [p3, p4]
layout = gridplot([row1, row2])
output_file('bokeh.html')
show(layout)
Cell 2
tab1 = Panel(child=p1, title='Latin America')
tab2 = Panel(child=p2, title='Africa')
tab3 = Panel(child=p3, title='Asia')
tab4 = Panel(child=p4, title='Europe')
layout = Tabs(tabs=[tab1, tab2, tab3, tab4])
output_file('bokeh.html')
show(layout)
In the env1, I could run cell 1, cell 2, and cell 1 again without any problem.
However, in env2, after executing cell 1, then trying to run cell 2, I got an error :
RuntimeError: Models must be owned by only a single document, WheelZoomTool(id='1130', ...) is already in a doc
My questions are:
- Is it a bug in bokeh 2.0.0?
- What does it mean by Models in the error message?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 19 (11 by maintainers)
Thanks, @bryevdv. I can understand what you are coming from. Appreciated your help. Cheers.
As an aside, we have our own live tutorial notebooks that can be used instead:
https://mybinder.org/v2/gh/bokeh/bokeh-notebooks/master?filepath=tutorial%2F00 - Introduction and Setup.ipynb
I think the actual fix here is to try and get whoever made this other tutorial to update it to be better and more idiomatic. Can you specify where this tutorial is, or who made it?