Using Perspective's Jupyter widget in Bokeh with ipywidgets_bokeh

I’ve been using a variety of ipywidgets in bokeh (actually panel) for a while - it’s fun :grinning:

I expected to be able to use Perspective’s existing Jupyter widget, too, but it did not “just work” (unlike others such as ipyvolume, ipyleaflet, ipymonaco, etc). I don’t know if it’s an issue with Perspective’s widget, or with ipywidgets_bokeh (or me :slight_smile: ). @mateusz kindly suggested that if I posted here, he might be able to give me some hints:

Sample code:

import pandas as pd
df = pd.DataFrame([[1,2,3],[4,5,6]],columns=["A","B","C"])

from perspective import PerspectiveWidget
p = PerspectiveWidget(df)

from ipywidgets_bokeh import IPyWidget
w = IPyWidget(widget=p,width=600,height=400)

from bokeh.plotting import curdoc
from bokeh.layouts import column

layout = column([w])
doc = curdoc()
doc.add_root(layout) 

Which I serve with bokeh, resulting in:

I guess the important info above is:

GET http://localhost:5006/@jupyterlab/coreutils.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost:5006/@jupyterlab/application.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost:5006/@jupyterlab/apputils.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost:5006/@jupyterlab/docregistry.js net::ERR_ABORTED 404 (Not Found)

require.min.js:1 Uncaught (in promise) Error: Script error for "@jupyterlab/coreutils", needed by: @finos/perspective-jupyterlab
http://requirejs.org/docs/errors.html#scripterror
    at makeError (require.min.js:1)
    at HTMLScriptElement.onScriptError (require.min.js:1)

I installed perspective 0.5.2 on linux using conda. The perspective widget (and first 4 lines from the example above) work in jupyter lab in the same environment.

The code for Perspective’s widget is at https://github.com/finos/perspective/tree/v0.5.2/packages/perspective-jupyterlab

Is some part of jupyter lab/widgets missing from ipywidgets_bokeh? Or does perspective do something strange/wrong? Or something else…?

I’m hoping for a quick pointer/guess, but otherwise I’ll start to debug this myself at some point (I’m not at all familiar with typescript/javascript/jupyter lab imports and packaging these days…).

Thanks!

P. S. I’m aware of PerspectiveViewer Extension (which is great!), but here I’d like to understand/document issues that people might encounter when using ipywidgets in bokeh.

1 Like