I use bokeh as a plotting system for a long data reduction pipeline which keeps producing new plots and sends them to the same server, started separately using bokeh serve. The pipeline is in Python.
The way I use is to push the session at the beginning with an empty or dummy figure, in a column layout.
When I want a new figure to be displayed, I retrieve the layout, and replace the children with the new figure.
This used to work perfectly on 1.4.3. On 2.0.0, the first dummy figure is displayed, but the following figures are ignored. I have run bokeh serve in trace log level and in 1.4.3 I see the new figure being processed, in 2.0.0, there are no messages whatsoever when the children.insert command is used.
Here is an example code. When run in 1.4.3, after 5 seconds the second figure appears. In 2.0.0, only the first figure appears, then after 5 seconds the code exits with no errors.
from bokeh.client import push_session,pull_session from bokeh.io import curdoc from bokeh.plotting.figure import figure from bokeh.layouts import column import time p = figure(plot_width=400, plot_height=400, name = 'main_plot') r = p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5) mainLayout = column(children=[p], name='mainLayout') curdoc().add_root(mainLayout) bokeh_session = push_session(curdoc()) bokeh_session.show(mainLayout) print("waiting 5 seconds") time.sleep(5) p1 = figure(plot_width=400, plot_height=400, name='main_plot') r1 = p1.circle([2, 3, 4, 5, 6], [10, 1, 3, 1, 1], size=20, color="red", alpha=0.5) layout = curdoc().get_model_by_name('mainLayout') figure = curdoc().get_model_by_name('main_plot') children = layout.children children.remove(figure) children.insert(0, p1)
So the question is: how do I reuse an existing server to display a completely new figure in 2.0.0 ?