jupyter / dashboards_server

[RETIRED] Server that runs and renders Jupyter notebooks as interactive dashboards
Other
181 stars 48 forks source link

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

Open madhu-mallisseri opened 8 years ago

madhu-mallisseri commented 8 years ago

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)

parente commented 8 years ago

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

madhu-mallisseri commented 8 years ago

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.

parente commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

parente commented 8 years ago

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.

tkzeng commented 7 years ago

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

@parente Is there a solution for this yet?

parente commented 7 years ago

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.