Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
p-himik opened this issue Jun 16, 2020 · 4 comments
Closed

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

p-himik opened this issue Jun 16, 2020 · 4 comments

Comments

@p-himik
Copy link
Contributor

p-himik commented Jun 16, 2020

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
@mattpap
Copy link
Contributor

mattpap commented Jun 16, 2020

bokeh and bokehjs disagree whether LabelSet.text_align is a vectorized property. This is a regression after recent strictening of bokehjs' properties system.

@bryevdv
Copy link
Member

bryevdv commented Jun 16, 2020

FYI this is breaking the Dask dashboard we should plan to release a 2.1.1 by early next week.

@harmbuisman
Copy link
Contributor

@p-himik , thanks for creating the issue.

I get another similar error in my server:
bokeh.core.property.bases.DeserializationError: Enum('top', 'middle', 'bottom', 'alphabetic', 'hanging', 'ideographic') expected str, got {'value': 'middle'} of type dict

Unlike the LabelSet.text_align I cannot pinpoint which component this is, we do not set any attribute to "middle" in our code

@mattpap
Copy link
Contributor

mattpap commented Jun 16, 2020

Same problem. I'm going to review all those properties (visual mixins) when fixing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants