panel icon indicating copy to clipboard operation
panel copied to clipboard

[WIP] Compatibility with Bokeh 3.0 (round 2)

Open hoxbro opened this issue 1 year ago • 19 comments

Definitely a WIP

Status / Todo

(Not an exhaustive list)

  • [x] Get panel serve to run with a simple script
  • [x] Get the unit tests to pass in the CI
  • [x] Get panel widgets to work in a notebook
  • [ ] Get examples to pass in the CI
  • [ ] Get UI tests to pass in the CI
  • [ ] Support templates
  • [ ] Run examples notebooks locally to verify everything is as it should be
  • [ ] Implement changes done to bokeh.models.DatePicker in panel.models.DatetimePicker

Simple panel script running

With these changes, I can get the panel to build with bokeh 3.0 and serve a simple script as this with BOKEH_DEV=true BOKEH_RESOURCES=server panel serve:

import panel as pn
import bokeh

print(pn.__version__)
print(bokeh.__version__)

pn.panel(f"TEST {bokeh.__version__}").servable()

image


I did not continue on Philipps original pull requests https://github.com/holoviz/panel/pull/3072 as it is six months old, and I still want to use it for lookup.

Linting and removal of commented code lines will be done later.

hoxbro avatar Aug 12 '22 12:08 hoxbro

Error: unknown property panel.models.location.Location.reload

This required change from, e.g.:

static init_SomeModel {}

to

static {}

(see 9698782).

mattpap avatar Aug 12 '22 14:08 mattpap

Perfect! With your change, I can now serve the simplest panel app.

hoxbro avatar Aug 12 '22 14:08 hoxbro

Unittest failing:

FAILED panel/tests/test_links.py::test_bokeh_figure_jslink - ValueError: failed to validate TextInput(id='1301', ...).value: expected a value of type str, got nan of type float
FAILED panel/tests/test_util.py::test_render_mimebundle - TypeError: standalone_docs_json_and_render_items() takes 1 positional argument but 2 were given
FAILED panel/tests/io/test_embed.py::test_embed_merged_sliders - AssertionError: assert [{'attr': 'te..., 'new': '1'}] == [{'attr': 'te...'1881'}, ...}]

The majority are changes that are related to holoviews and plot_*, which I think should be updated to outer_*.

FAILED panel/tests/test_links.py::test_pnwidget_hvplot_links - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/test_links.py::test_bkwidget_hvplot_links - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/test_links.py::test_hvplot_jscallback - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/test_links.py::test_link_with_customcode - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/test_template.py::test_template_links_axes - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/io/test_save.py::test_static_path_in_holoviews_save - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_pane_switch_backend - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_pane_bokeh_renderer - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_pane_initialize_empty - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_with_widgets - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_updates_widgets - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_widgets_update_plot - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_with_widgets_not_shown - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_layouts - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_linked_axes - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_linked_axes_flexbox - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_linked_axes_merged_ranges - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_linked_x_axis - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_axiswise_not_linked_axes - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_shared_axes_opt_not_linked_axes - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_not_linked_axes - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_link_across_panes - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_link_after_adding_item - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_link_within_pane - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
FAILED panel/tests/pane/test_holoviews.py::test_holoviews_property_override - AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height

hoxbro avatar Aug 12 '22 16:08 hoxbro

(...) plot_*, which I think should be updated to outer_*.

No, plot_width -> width. outer_width is a computed readonly value of actual width, as computed by the layout.

mattpap avatar Aug 12 '22 18:08 mattpap

assert [{'attr': 'te..., 'new': '1'}] == [{'attr': 'te...'1881'}, ...}]

You should run pytest with -vv. However, I'm pretty sure it's just old that needs to be removed (or something along the line).

mattpap avatar Aug 12 '22 18:08 mattpap

standalone_docs_json_and_render_items() takes 1 positional argument but 2 were given

suppress_callback_warning is now a keyword only argument.

mattpap avatar Aug 12 '22 18:08 mattpap

Failing examples (on ubuntu)

FAILED examples/user_guide/Deploy_and_Export.ipynb::Cell 9
FAILED examples/user_guide/Pipelines.ipynb::Cell 8
FAILED examples/user_guide/Pipelines.ipynb::Cell 9
FAILED examples/user_guide/Pipelines.ipynb::Cell 12
FAILED examples/user_guide/Pipelines.ipynb::Cell 13
FAILED examples/user_guide/Pipelines.ipynb::Cell 16
FAILED examples/reference/widgets/Tabulator.ipynb::Cell 33
FAILED examples/reference/widgets/Tabulator.ipynb::Cell 34
FAILED examples/reference/widgets/Tabulator.ipynb::Cell 35
FAILED examples/reference/widgets/Tabulator.ipynb::Cell 47
FAILED examples/gallery/links/bokeh_property_editor.ipynb::Cell 5
FAILED examples/gallery/param/reactive_plots.ipynb::Cell 3
FAILED examples/gallery/simple/iris_kmeans.ipynb::Cell 1

hoxbro avatar Aug 13 '22 10:08 hoxbro

Trying to run panel in a notebook and get the following console errors:

import os
os.getenv("BOKEH_RESOURCES")

import panel as pn
pn.extension()

pn.widgets.IntSlider()

image

Kernel: restarting (2e904f74-ba0f-4af4-b441-67884fd14eee) jlab_core.081dc2b13065c79d8463.js:2:997341
Some cookies are misusing the recommended “SameSite“ attribute 38
Connection lost, reconnecting in 0 seconds. jlab_core.081dc2b13065c79d8463.js:2:996773
Starting WebSocket: ws://localhost:8889/api/kernels/2e904f74-ba0f-4af4-b441-67884fd14eee jlab_core.081dc2b13065c79d8463.js:2:982794
Kernel: starting (2e904f74-ba0f-4af4-b441-67884fd14eee) jlab_core.081dc2b13065c79d8463.js:2:997341
Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early 272.3fcd6d7045eecfb56da6.js:1:10870
Bokeh: BokehJS not loaded, scheduling load and callback at 
Date Sat Aug 13 2022 12:19:11 GMT+0200 (Central European Summer Time)
Untitled.ipynb line 2 > injectedScript:44:13
Bokeh: injecting link tag for BokehJS stylesheet:  https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css Untitled.ipynb line 2 > injectedScript:66:15
Bokeh: injecting link tag for BokehJS stylesheet:  https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css Untitled.ipynb line 2 > injectedScript:66:15
Bokeh: all BokehJS libraries/stylesheets loaded Untitled.ipynb line 2 > injectedScript:49:17
Bokeh: BokehJS plotting callback run at 
Date Sat Aug 13 2022 12:19:11 GMT+0200 (Central European Summer Time)
Untitled.ipynb line 2 > injectedScript:1717:15
[bokeh] setting log level to: 'info' Untitled.ipynb line 2 > injectedScript:342:1317
Bokeh: all callbacks have finished Untitled.ipynb line 2 > injectedScript:27:13
Error: Promised response from onMessage listener went out of scope background.js:841:170
Uncaught Error: panel.models.comm_manager.CommManager(1002).plot_id is unset
    get_value http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:341
    get http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:338
    r http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:1546
    _decode_object_ref http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:371
    _decode http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:371
    _decode_plain_array http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:371
    c http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:337
    _decode_plain_array http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:371
    _decode http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:371
    n http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:371
    decode http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:371
    from_json http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:324
    embed_items_notebook http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:406
    embed_document http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:5
    <anonymous> http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:17
    <anonymous> http://localhost:8889/lab/workspaces/auto-Y/tree/Untitled.ipynb line 2 > injectedScript:33
    attachWidget http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    insertWidget http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _insertOutput http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    onModelChanged http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    m http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    l http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    emit http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _onListChanged http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    m http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    l http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    emit http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    push http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _add http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    add http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _onIOPub http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _handleIOPub http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    handleMsg http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _handleMessage http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _msgChain http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    promise callback*19883/b/this._onWSMessage http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _createSocket http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    setTimeout handler*_reconnect http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    reconnect http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    restart http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    restartKernel http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    restart http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    restartKernel http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    r http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    execute http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    triggerActiveItem http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _evtMouseUp http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    handleEvent http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    onBeforeAttach http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    processMessage http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    b http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    t http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    r http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    c http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    open http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _openChildMenu http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _evtMouseDown http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    handleEvent http://localhost:8889/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
Untitled.ipynb line 2 > injectedScript:341:1600
Error: Promised response from onMessage listener went out of scope 2 background.js:841:170

hoxbro avatar Aug 13 '22 10:08 hoxbro

panel.models.comm_manager.CommManager(1002).plot_id is unset

Given this definition:

plot_id = String()
plot_id: p.Property<string | null>
plot_id:        [ String    ],

the behavior is correct. Bokeh's properties don't allow implicit None anymore. On bokeh's side there's an intrinsic default value "" for plot_id. However, bokehjs doesn't allow intrinsic defaults, so in this case the value is undefined which results in this property being unset.

To support nullable properties, the type needs to be wrapped in Nullable(...) in both bokeh and bokehjs, and an explicit default value null provided in bokehjs, so:

plot_id = Nullable(String)
plot_id: p.Property<string | null>
plot_id:        [ Nullable(String), null ],

mattpap avatar Aug 13 '22 12:08 mattpap

plot_id = Nullable(String)

The intrinsic default is None for this type.

mattpap avatar Aug 13 '22 12:08 mattpap

To create a required (no default value) nullable property, use:

plot_id = Required(Nullable(String))

Unless plot_id is explicitly set, there will be a runtime exception whenever plot_id is accessed, serialized, etc.

mattpap avatar Aug 13 '22 12:08 mattpap

I have implemented your suggested changes but still got the error.

From what I could see in the python codebase, when CommManager was initiated, it was always done with plot_id as an argument and print(self.plot_id) in CommManager.__init__ confirmed it (at least for me).

What seems to be the problem is that plot_id, comm_id, and client_comm_id is no longer available doing the constructor(). I have moved all the logic into initialize but am unsure if this is correct.

With the changes in https://github.com/holoviz/panel/pull/3752/commits/6c94a75ff649b9b38c007262cc652e121bab33de, I can get a Panel widget and pane to render in Jupyter. The problem is I get no sync with the widget and Python, and I have little idea where to look to get this to work.

image

If I use Kernel -> Restart the notebook and run all Cells... I get the following error. Could this be related to moving the functionality in constructor() -> initialize()?

console.log
Starting application in workspace: "auto-b" jlab_core.081dc2b13065c79d8463.js:2:5778
Some cookies are misusing the recommended “SameSite“ attribute 128
No exact match found for python3, using kernel python3 that matches language=python jlab_core.081dc2b13065c79d8463.js:2:113030
Starting WebSocket: ws://localhost:8888/api/kernels/dd72934a-7de8-490e-af4e-a0e66a3eaa2a jlab_core.081dc2b13065c79d8463.js:2:982794
Starting WebSocket: ws://localhost:8888/api/kernels/dd72934a-7de8-490e-af4e-a0e66a3eaa2a jlab_core.081dc2b13065c79d8463.js:2:982794
Starting WebSocket: ws://localhost:8888/api/kernels/dd72934a-7de8-490e-af4e-a0e66a3eaa2a jlab_core.081dc2b13065c79d8463.js:2:982794
Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early 272.3fcd6d7045eecfb56da6.js:1:10870
Kernel: restarting (dd72934a-7de8-490e-af4e-a0e66a3eaa2a) jlab_core.081dc2b13065c79d8463.js:2:997341
Connection lost, reconnecting in 0 seconds. jlab_core.081dc2b13065c79d8463.js:2:996773
Starting WebSocket: ws://localhost:8888/api/kernels/dd72934a-7de8-490e-af4e-a0e66a3eaa2a jlab_core.081dc2b13065c79d8463.js:2:982794
Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early 272.3fcd6d7045eecfb56da6.js:1:10870
Bokeh: BokehJS not loaded, scheduling load and callback at 
Date Mon Aug 15 2022 18:38:50 GMT+0200 (Central European Summer Time)
notebook.ipynb line 2 > injectedScript:44:13
Bokeh: injecting link tag for BokehJS stylesheet:  https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css notebook.ipynb line 2 > injectedScript:66:15
Bokeh: injecting link tag for BokehJS stylesheet:  https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css notebook.ipynb line 2 > injectedScript:66:15
Bokeh: injecting script tag for BokehJS library:  https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js notebook.ipynb line 2 > injectedScript:106:15
Bokeh: all BokehJS libraries/stylesheets loaded notebook.ipynb line 2 > injectedScript:49:17
Bokeh: BokehJS plotting callback run at 
Date Mon Aug 15 2022 18:38:50 GMT+0200 (Central European Summer Time)
notebook.ipynb line 2 > injectedScript:1717:15
[bokeh] setting log level to: 'info' notebook.ipynb line 2 > injectedScript:342:1317
Bokeh: all callbacks have finished notebook.ipynb line 2 > injectedScript:27:13
[bokeh] document idle at 6 ms 2 notebook.ipynb line 2 > injectedScript:324:1391
Source map error: Error: request failed with status 404
Resource URL: http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463
Source Map URL: jlab_core.081dc2b13065c79d8463.js.map?v=081dc2b13065c79d8463
Error: Promised response from onMessage listener went out of scope 39 background.js:841:170
Kernel: restarting (dd72934a-7de8-490e-af4e-a0e66a3eaa2a) jlab_core.081dc2b13065c79d8463.js:2:997341
Connection lost, reconnecting in 0 seconds. jlab_core.081dc2b13065c79d8463.js:2:996773
Starting WebSocket: ws://localhost:8888/api/kernels/dd72934a-7de8-490e-af4e-a0e66a3eaa2a jlab_core.081dc2b13065c79d8463.js:2:982794
Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early 272.3fcd6d7045eecfb56da6.js:1:10870
Bokeh: BokehJS not loaded, scheduling load and callback at 
Date Mon Aug 15 2022 18:42:30 GMT+0200 (Central European Summer Time)
notebook.ipynb line 2 > injectedScript:44:13
Bokeh: injecting link tag for BokehJS stylesheet:  https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css notebook.ipynb line 2 > injectedScript:66:15
Bokeh: injecting link tag for BokehJS stylesheet:  https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css notebook.ipynb line 2 > injectedScript:66:15
Bokeh: all BokehJS libraries/stylesheets loaded notebook.ipynb line 2 > injectedScript:49:17
Bokeh: BokehJS plotting callback run at 
Date Mon Aug 15 2022 18:42:30 GMT+0200 (Central European Summer Time)
notebook.ipynb line 2 > injectedScript:1717:15
[bokeh] setting log level to: 'info' notebook.ipynb line 2 > injectedScript:342:1317
Bokeh: all callbacks have finished notebook.ipynb line 2 > injectedScript:27:13
[bokeh] document idle at 4 ms 2 notebook.ipynb line 2 > injectedScript:324:1391
Uncaught TypeError: t.document is null
    process_events http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:1546
    _document_changed http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:1546
    setTimeout handler*_document_changed http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:1546
    _document_listener http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:1546
    _trigger_on_change http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:324
    add_root http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:324
    from_json http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:324
    embed_items_notebook http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:406
    embed_document http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:5
    <anonymous> http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:17
    <anonymous> http://localhost:8888/lab/workspaces/auto-b/tree/notebook.ipynb line 2 > injectedScript:33
    attachWidget http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    insertWidget http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _insertOutput http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    onModelChanged http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    m http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    l http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    emit http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _onListChanged http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    m http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    l http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    emit http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    push http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _add http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    add http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _onIOPub http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _handleIOPub http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    handleMsg http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _handleMessage http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _msgChain http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    promise callback*19883/b/this._onWSMessage http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _createSocket http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    setTimeout handler*_reconnect http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    reconnect http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    restart http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    restartKernel http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    restart http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    restartAndRunAll http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    r http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    execute http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    triggerActiveItem http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _evtMouseUp http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    handleEvent http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    onBeforeAttach http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    processMessage http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    b http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    t http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    r http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    c http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    open http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _openChildMenu http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    _evtMouseDown http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
    handleEvent http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2
2 notebook.ipynb line 2 > injectedScript:1546:1917
Error: Promised response from onMessage listener went out of scope background.js:841:170
Cannot execute key binding 'F11': command 'debugger:stepIn' is not enabled. jlab_core.081dc2b13065c79d8463.js:2:1355451
Source map error: Error: request failed with status 404
Resource URL: http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463
Source Map URL: jlab_core.081dc2b13065c79d8463.js.map?v=081dc2b13065c79d8463

I could see in other BokehJS models that override was used, so I did it in CommManager.


Questions:

  • Is it correct to use initialize?
  • Should override be used, or is it an opt-in?
  • How do I get synchronization between the widget and python? (Very easy questions to ask, properly very hard to answer).

hoxbro avatar Aug 15 '22 16:08 hoxbro

Is it correct to use initialize?

That's the only way. If inheriting from HasProps, one should not touch the constructor. This constructor stub is only there for type purpose, so that arguments to the constructor can be overriden accordingly. However, it should contain no custom logic, unless you really know what you're doing. All initialization should happen in initialize(), as this can (usually will) affect correctness of model construction, which differs in JS and when initializing from JSON (which involves deferred initialization).

Should override be used, or is it an opt-in?

It's beneficial, but optional by default. You can add:

   "noImplicitOverride": true,

to panel's tsconfig.json to enforce this. Though given this will require a lot of changes across the code base. I would recommend enabling it anyway, however after the migration is done.

How do I get synchronization between the widget and python? (Very easy questions to ask, properly very hard to answer).

Sync fails because of t.document is null. This will require some investigation. I will look into this when I'm done with the current round of layout changes.

mattpap avatar Aug 15 '22 17:08 mattpap

@philippjfr removed your pin commit as it could not solve the environment [ref].

Have solved some notebook related problems:

  1. The introduction of bokeh.core.property.vectorization import Field, Value which is mostly done here. I'm not super happy about my implementation.
  2. range no longer working with ColumnDataSource [ref]

hoxbro avatar Aug 19 '22 16:08 hoxbro

Buffers are now a custom class bokeh.core.serialization.Buffer and not a tuple(?) which can be unpacked.

This gives a problem here:

https://github.com/holoviz/panel/blob/84d8aecaa9cd5bafe56e28ec6d7adcfd6da8fb77/panel/io/document.py#L160-L163

And here:

https://github.com/holoviz/panel/blob/84d8aecaa9cd5bafe56e28ec6d7adcfd6da8fb77/panel/io/notebook.py#L74-L76

hoxbro avatar Aug 19 '22 16:08 hoxbro

buffers are now a custom class bokeh.core.serialization.Buffer and not a tuple(?) which can be unpacked.

Yes, see here https://github.com/bokeh/bokeh/blob/branch-3.0/bokeh/protocol/message.py#L271-L277. I'm wondering if panel really has to go that low-level. I suppose this is something to discuss after the migration.

EDIT: https://github.com/bokeh/bokeh/blob/9175e148b516c3d27fc78f996370d4ef1f5f5e01/src/bokeh/protocol/message.py#L271-L277

mattpap avatar Aug 19 '22 17:08 mattpap

range no longer working with ColumnDataSource

We may restore that as discussed in the referenced issue. I also implemented actual serialization support for range iterators, but actually supporting this on bokehjs' side is a more complex matter.

mattpap avatar Aug 19 '22 17:08 mattpap

Codecov Report

Merging #3752 (b782f3a) into master (a1fc86d) will decrease coverage by 8.60%. The diff coverage is 69.69%.

:exclamation: Current head b782f3a differs from pull request most recent head 0fb3993. Consider uploading reports for the commit 0fb3993 to get more accurate results

@@            Coverage Diff             @@
##           master    #3752      +/-   ##
==========================================
- Coverage   83.58%   74.97%   -8.61%     
==========================================
  Files         223      222       -1     
  Lines       33243    32705     -538     
==========================================
- Hits        27785    24521    -3264     
- Misses       5458     8184    +2726     
Flag Coverage Δ
ui-tests ?
unitexamples-tests 74.97% <69.69%> (+0.31%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
panel/io/resources.py 86.71% <ø> (-0.10%) :arrow_down:
panel/models/widgets.py 100.00% <ø> (ø)
panel/template/fast/theme.py 100.00% <ø> (ø)
panel/template/material/__init__.py 100.00% <ø> (ø)
panel/tests/io/test_embed.py 99.42% <ø> (ø)
panel/io/notebook.py 49.75% <20.00%> (-0.50%) :arrow_down:
panel/io/document.py 54.87% <42.30%> (-1.03%) :arrow_down:
panel/io/convert.py 28.31% <50.00%> (-43.92%) :arrow_down:
panel/models/comm_manager.py 68.75% <100.00%> (ø)
panel/template/theme/__init__.py 96.15% <100.00%> (ø)
... and 72 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Aug 20 '22 11:08 codecov[bot]

@mattpap I have added a script that gives an overview of many of Panels custom Bokeh models in 08857d2.

I have run it with bokeh 2.4 and get the following HTML: models_bokeh2.zip

hoxbro avatar Aug 31 '22 15:08 hoxbro

Progress

Screen Shot 2022-10-08 at 16 58 45 Screen Shot 2022-10-08 at 16 59 11 Screen Shot 2022-10-08 at 16 59 41

philippjfr avatar Oct 08 '22 14:10 philippjfr

No more JavaScript build errors but some notes on things I removed:

  • Card background
  • Avoiding re-render when setting/unsetting pn-loading css class
  • Terminal cell width/height computations might be incorrect

philippjfr avatar Oct 08 '22 16:10 philippjfr