Bokeh 2.0.0 breaks application

Hi,

I am running a bokeh application with an html as output. After updating bokeh from 1.4.0 to 2.0.0 my and changing a couple of callbacks, my output gives me an empty html. Python does not show any errors.

The errors I obtain in JS console are the following

[bokeh] – "Failed to fetch JSON from null with code 0"

and

Unhandled Promise Rejection: TypeError: undefined is not an object

I do not really know what to do about it. Many thanks for your help in advance!

Best wishes,
Daniel

Hi @d-que we need a complete reproducer to actually run and investigate to be able to speculate.

@Bryan I am happy to provide it, but I don’t quite know, what you mean with this exactly. I am happy to send over my code in a pm.

Code in a PM is fine. I just need something to run (and instructions to run).

PM is sent. Many thanks for your help :slight_smile:

I quickly went back to version 1.4.0 and it worked again.

@d-que looking at your code, it seems to run if this line is commented out:

# dropdown.js_on_change('value', drop_cb)

And looking at the ref docs for Dropdown, I don’t see any value property. The CI integration tests for this widget use the menu_item_clieck event, like this:

button.js_on_event('menu_item_click', CustomJS(code=...))

and

def cb(event):
    item = event.item
    if item == "item_1_value":
        source.data = dict(x=[10, 20], y=[10, 10])
    elif item == "item_2_value":
        source.data = dict(x=[100, 200], y=[100, 100])
    elif item == "item_3_value":
        source.data = dict(x=[1000, 2000], y=[1000, 1000])
button.on_event('menu_item_click', cb)

We could probably do a better job about warning earlier and more loudly if a user tries to set up a change handler for a property that does not exist, but that appears to be the root of the issue here.

@Bryan Many thanks for the help! I was just changing my callbacks quickly after the old callback like callback=… was removed.

1 Like

I fell into this while upgrading to 2.x. For the CustomJS js_on_event, how to does one reference the selected item from inside the javascript. No longer cb_obj.value any longer…

Thanks,

Richard

You can use

dropdown.js_on_click(CustomJS(code="const item = this.item;"))

Thanks! That did the trick :slight_smile:

In the “teach to fish” department, do you know where one goes in the documentation fo find that?

Richard

js_on_click: bokeh.models.widgets.buttons — Bokeh 2.3.3 Documentation

Internally, it uses js_on_event: bokeh.events — Bokeh 2.4.2 Documentation

this.item I took from examples. But given the docs above, I guess you could also use cb_obj.item. Didn’t check it though.

Thanks again. Indeed I’d seen event.item in examples and had used that in my python Dropdown menu callbacks.