Closing a tab, error message raise. On next action of generating another new tab, the closed tab appeared again along. This happens on bokeh 2.3.2, but was working fine on previous version 2.2.1.
did i miss out something on the code, or behaviour has been changed?
code to reproduce the error:
import numpy as np
import pandas as pd
from bokeh.io import show, output_notebook
from bokeh.plotting import figure
from bokeh.models import Panel, Tabs
from bokeh.events import Tap
output_notebook()
def plot_tab(doc):
def callback():
p2 = figure(plot_width=300, plot_height=300)
p2.diamond(x='b', y='c', size=10, source=df)
tab2 = Panel(child=p2, title='tab2', closable=True)
tabs.tabs.insert(1,tab2)
#tabs.tabs.append(tab2)
tabs.active=1
df= pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
columns=['a', 'b', 'c'])
p1 = figure(plot_width=300, plot_height=300, tools='tap')
p1.line(x='a', y='b', source=df)
p1.on_event(Tap, callback)
tab1 = Panel(child=p1, title='tab1')
tabs = Tabs(tabs=[tab1])
doc.add_root(tabs)
show(plot_tab)
the error msg when close a tab:
message: Message 'PATCH-DOC' content: {'events': [{'kind': 'ModelChanged', 'model': {'id': '1059'}, 'attr': 'tabs', 'new': [{'id': '1058'}, {'id': '1137'}]}], 'references': []}
error: DeserializationError("Instance(Panel) failed to deserialize reference to {'id': '1058'}")
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\server\protocol_handler.py", line 90, in handle
work = await handler(message, connection)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\server\session.py", line 67, in _needs_document_lock_wrapper
result = func(self, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\server\session.py", line 261, in _handle_patch
message.apply_to_document(self.document, self)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\protocol\messages\patch_doc.py", line 100, in apply_to_document
doc._with_self_as_curdoc(lambda: doc.apply_json_patch(self.content, setter))
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\document.py", line 1198, in _with_self_as_curdoc
return f()
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\protocol\messages\patch_doc.py", line 100, in <lambda>
doc._with_self_as_curdoc(lambda: doc.apply_json_patch(self.content, setter))
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\document.py", line 411, in apply_json_patch
patched_obj.set_from_json(attr, value, models=references, setter=setter)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\has_props.py", line 412, in set_from_json
descriptor.set_from_json(self, json, models, setter)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\descriptors.py", line 623, in set_from_json
return super().set_from_json(obj, self.property.from_json(json, models), models, setter)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\container.py", line 70, in from_json
return self._new_instance([ self.item_type.from_json(item, models) for item in json ])
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\container.py", line 70, in <listcomp>
return self._new_instance([ self.item_type.from_json(item, models) for item in json ])
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\instance.py", line 93, in from_json
raise DeserializationError(f"{self} failed to deserialize reference to {json}")
bokeh.core.property.bases.DeserializationError: Instance(Panel) failed to deserialize reference to {'id': '1058'}```