I’ve hit this problem recently and looking for a bit of explanation of how I might be able to fix it.
We use Bokeh mostly with custom visualizations created from functions in imported Python modules (there is no module-level state and the ColumnDataSource objects are created a new objects each time.
When using these normally we have no problem.
In a new scenario we’d like to be able to save (temporarily, not to disk) the generated figures in a Python object. We’re calculating a bunch of results and Bokeh visualizations and then assigning each to an object attribute. Trying to show these again sometimes works and sometimes throws the error:
Models must be owned by only a single document, CDSView(id=xxxx....
These are all in a Jupyter notebook and trying to display them using bokeh.io.show (I’ve since read in a thread here that show() shouldn’t be called multiple times). Do I need to explicitly add these to a Document object? Should I be using something other than show() to display the figures?
I’m assuming that "show"ing a figure multiple times results in the entire Bokeh JS to be duplicated - and hence the colliding CSD ids.
I found this older thread (almost) useful
although doesn’t quite match our scenario.