Skip to content

[BUG] Unable to set LabelSet.text_align with bokeh serve #10181

Description

@p-himik

ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)

Bokeh 2.1.0

Description of expected behavior and the observed behavior

Setting LabelSet.text_align works just fine with a static HTML document, but with bokeh serve it fails with a deserialization error.

Complete, minimal, self-contained example code that reproduces the issue

from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, LabelSet, Range1d
from bokeh.plotting import figure

source = ColumnDataSource(data=dict(height=[66, 71, 72, 68, 58, 62],
                                    weight=[165, 189, 220, 141, 260, 174],
                                    names=['Mark', 'Amir', 'Matt', 'Greg', 'Owen', 'Juan']))

p = figure(x_range=Range1d(140, 275), y_range=Range1d(50, 80))
p.circle(165, 66)

p.add_layout(LabelSet(x='weight', y='height', text='names',
                      source=source, text_align='center'))

curdoc().add_root(p)

Stack traceback and/or browser JavaScript console output

2020-06-16 17:44:30,904 error handling message
 message: Message 'PATCH-DOC' content: {'references': [], 'events': [{'kind': 'ModelChanged', 'model': {'id': '1038'}, 'attr': 'text_align', 'new': {'value': 'center'}}, {'kind': 'ModelChanged', 'model': {'id': '1002'}, 'attr': 'reset_start', 'new': 140}, {'kind': 'ModelChanged', 'model': {'id': '1002'}, 'attr': 'reset_end', 'new': 275}, {'kind': 'ModelChanged', 'model': {'id': '1003'}, 'attr': 'reset_start', 'new': 50}, {'kind': 'ModelChanged', 'model': {'id': '1003'}, 'attr': 'reset_end', 'new': 80}]} 
 error: DeserializationError("Enum('left', 'right', 'center') expected str, got {'value': 'center'} of type dict")
Traceback (most recent call last):
  File "/home/p-himik/dev/git/bokeh/bokeh/server/protocol_handler.py", line 90, in handle
    work = await handler(message, connection)
  File "/home/p-himik/dev/git/bokeh/bokeh/server/session.py", line 67, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "/home/p-himik/dev/git/bokeh/bokeh/server/session.py", line 261, in _handle_patch
    message.apply_to_document(self.document, self)
  File "/home/p-himik/dev/git/bokeh/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 "/home/p-himik/dev/git/bokeh/bokeh/document/document.py", line 1150, in _with_self_as_curdoc
    return f()
  File "/home/p-himik/dev/git/bokeh/bokeh/protocol/messages/patch_doc.py", line 100, in <lambda>
    doc._with_self_as_curdoc(lambda: doc.apply_json_patch(self.content, setter))
  File "/home/p-himik/dev/git/bokeh/bokeh/document/document.py", line 411, in apply_json_patch
    patched_obj.set_from_json(attr, value, models=references, setter=setter)
  File "/home/p-himik/dev/git/bokeh/bokeh/core/has_props.py", line 341, in set_from_json
    descriptor.set_from_json(self, json, models, setter)
  File "/home/p-himik/dev/git/bokeh/bokeh/core/property/descriptors.py", line 611, in set_from_json
    self.property.from_json(json, models),
  File "/home/p-himik/dev/git/bokeh/bokeh/core/property/bases.py", line 463, in from_json
    raise DeserializationError("%s expected %s, got %s of type %s" % (self, expected, json, type(json).__name__))
bokeh.core.property.bases.DeserializationError: Enum('left', 'right', 'center') expected str, got {'value': 'center'} of type dict

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions