
Hello, I am trying to render a graph using the boilerplate code from the tutorial site. My goal is to render a tree using a static layaout but I keep getting something called a DeserializationError.
The important code is here:
# create a Figure object
plot = figure(title='tree graph', tools="pan,reset,save")
graph = GraphRenderer()
# set its height, width, and fill_color
graph.node_renderer.glyph = Circle(radius=.5, fill_color='black')
plot.renderers.append(graph)
# add the rest of the assigned values to the data source
graph.edge_renderer.data_source.data = dict(
start=src,
end=tar)
node_indices = list(range(len(x)))
graph_layout = dict(zip(node_indices, zip(x, y)))
# use the provider model to supply coordinates to the graph
graph.layout_provider = StaticLayoutProvider(graph_layout=graph_layout)
# display the plot
cur = curdoc()
cur.add_root(plot)
x and y are a list of coordinates, both with a length of 252. Src and tar are both have a length of 251, the number of edges needed for a tree.
The error i get is this:
message: Message 'PATCH-DOC' content: {'events': [{'kind': 'ModelChanged', 'model': {'id': '1028'}, 'attr': 'edge_renderer', 'new': {'id': '1036'}}], 'references': []}
error: DeserializationError("Instance(GlyphRenderer) failed to deserialize reference to {'id': '1036'}")
Traceback (most recent call last):
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\server\protocol_handler.py", line 97, in handle
work = await handler(message, connection)
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\server\session.py", line 93, in _needs_document_lock_wrapper
result = func(self, *args, **kwargs)
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\server\session.py", line 287, in _handle_patch
message.apply_to_document(self.document, self)
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\protocol\messages\patch_doc.py", line 115, in apply_to_document
invoke_with_curdoc(doc, lambda: doc.apply_json_patch(self.content, setter))
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\document\callbacks.py", line 408, in invoke_with_curdoc
return f()
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\protocol\messages\patch_doc.py", line 115, in <lambda>
invoke_with_curdoc(doc, lambda: doc.apply_json_patch(self.content, setter))
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\document\document.py", line 391, in apply_json_patch
DocumentPatchedEvent.handle_json(self, event_json, references, setter)
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\document\events.py", line 259, in handle_json
handler(doc, event_json, references, setter)
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\document\events.py", line 467, in _handle_json
patched_obj.set_from_json(attr, value, models=references, setter=setter)
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\core\has_props.py", line 384, in set_from_json
descriptor.set_from_json(self, json, models=models, setter=setter)
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\core\property\descriptors.py", line 376, in set_from_json
value = self.property.prepare_value(obj, self.name, self.property.from_json(json, models=models))
File "c:\users\jsbow\anaconda3\lib\site-packages\bokeh\core\property\instance.py", line 112, in from_json
raise DeserializationError(f"{self} failed to deserialize reference to {json}")
bokeh.core.property.bases.DeserializationError: Instance(GlyphRenderer) failed to deserialize reference to {'id': '1036'}
2021-10-14 01:00:05,787 error handling message
message: Message 'PATCH-DOC' content: {'events': [{'kind': 'ModelChanged', 'model': {'id': '1028'}, 'attr': 'node_renderer', 'new': {'id': '1032'}}], 'references': []}
error: DeserializationError("Instance(GlyphRenderer) failed to deserialize reference to {'id': '1032'}")
Model 1028 appears to be the graph grender, but I am unsure of why it is trying to change it to 1032 and how that is causing problems. Thank you for your help!
