dashboards_server icon indicating copy to clipboard operation
dashboards_server copied to clipboard

widget don't display after an event (Could not create view Error)

Open madhu-mallisseri opened this issue 8 years ago • 9 comments

I have a notebook (snippet below) which has an ipywidget button. I need to display a checkbox on click of the button. This works as expected in jupyter. When this notebook is deployed to a dashboard server, on click of button, checkbox is not displayed.

notebook:

from ipywidgets import *
from IPython.display import display

def show_widgets():
    c = widgets.Checkbox(
        description='check me',
        value=True,
    )
    display(c)

button = widgets.Button(
    description='Display checkbox'
)
display(button)

def on_button_clicked(b):
    show_widgets()

button.on_click(on_button_clicked)

JS Console error:

Error: Could not create view at new Error (native) at Error.WrappedError (http://...:3000/components/jupyter-js-widgets.js:4065:22) at promiseRejection (http://...:3000/components/jupyter-js-widgets.js:4156:30)

madhu-mallisseri avatar Apr 18 '16 14:04 madhu-mallisseri

@madhu-mallisseri Can you tell me more about your setup? Are you using the developer docker containers / images in this repo?

parente avatar Apr 18 '16 14:04 parente

I am using the setup as provided in the "All-in-one" example. https://gist.github.com/parente/527cea0481afe9fabbcd

modified the docker-compose.yml, to remove notebook container.

madhu-mallisseri avatar Apr 18 '16 15:04 madhu-mallisseri

Confirmed with the gist. Checking to see if things are better on master. If not, it's quite possible we don't have the right code in place to support ipywidgets dynamically creating other widgets.

parente avatar Apr 19 '16 01:04 parente

we don't have the right code in place to support ipywidgets dynamically creating other widgets.

Yep.

https://github.com/jupyter-incubator/dashboards_server/blob/master/public/js/widget-manager.js#L74

We track the initial pending kernel executions to link up the output of a code execution with an output area. But when the code execution is dynamically triggered by an existing widget after initial load, we don't have the source of the execution stashed anywhere in order to put the result into the DOM when it comes back.

parente avatar Apr 19 '16 01:04 parente

Here's what the nbextension for ipywidgets does:

https://github.com/ipython/ipywidgets/blob/d3d399188902626a083aadc0f48a9d6c18d8d7e3/widgetsnbextension/src/manager.js#L346

Relies on the notebook and code cell objects as well as the kernel to map message IDs to cells containing widgets. We don't have either so we'll have to invent something new.

parente avatar Apr 19 '16 01:04 parente

Notebook for future ref when we are in a position to tackle this: https://gist.github.com/parente/767147f18c69794f0cee190b6741a52f

parente avatar May 23 '16 18:05 parente

Possibly related, even simpler problem to tackle: ipywidget calls a function, function prints, print output comes in on a regular stream message (not comm), stream message is lost because the widget association is not known.

parente avatar May 26 '16 17:05 parente

we don't have the right code in place to support ipywidgets dynamically creating other widgets.

@parente Is there a solution for this yet?

tkzeng avatar Dec 16 '16 16:12 tkzeng

No and development has stalled.

The dashboard code has to be updated to use newer versions of the jupyterlab + ipywidgets packages before this bug can get tackled. Otherwise, the fix runs the risk of being immediately out of date and irrelevant.

parente avatar Dec 17 '16 03:12 parente