Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button callbacks don't work on JupyterLab? #2380

Closed
choldgraf opened this issue Apr 15, 2019 · 11 comments
Closed

Button callbacks don't work on JupyterLab? #2380

choldgraf opened this issue Apr 15, 2019 · 11 comments
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@choldgraf
Copy link

I just tried building a simple interface using a button w/ a callback to update a bqplot. When I was using Jupyter Lab, clicking the button didn't do anything. When I switched to the classic interface, it worked fine (running Voila also worked fine). Just wanted to flag this in case it's not a known bug.

@SylvainCorlay
Copy link
Member

They do work but print statements are not displayed. Output streams must be captured with an output widget.

@williamstein
Copy link
Contributor

They do work but print statements are not displayed. Output streams must be captured with an output widget.

Is this by design, or not yet implemented. Which behavior in this case is the right one?

  • A. print output should be displayed (like in Jupyter Classic)
  • B. print output should NOT be displayed (like in JupyterLab).

I ask because I'm also implementing ipywidget support for CoCalc, and I have to decide which choice to follow.

@williamstein
Copy link
Contributor

Nobody responded (ping: @jasongrout ?). My testing suggests the semantics in Jupyter classic is that if there is an output IOPUB message but no Output widget capturing it, and no cell is being explicitly executed, then the cell whose output contains the widget that caused this message gets the output appended.

More precisely, the output messages has parent_header.msg_id equal to the msg_id of the comm state update message that caused these output messages to appear. (I would have to add some info somewhere about which view caused the frontend model to change in order to know where to put the output. That sounds difficult, but possible.)

I'm going to leave this for after my first ipywidgets release. However, I would like to know -- in a perfect world -- which behavior (A or B) is officially right, and which is a bug?

@williamstein
Copy link
Contributor

I'm guessing B is a bug and A is right, because actual users would be more "surprised" by B than A, as evidenced by this issue being opened. Also, just silently ignoring output with no error message is definitely not desirable... and it's even in the docs...

@jasongrout
Copy link
Member

A is the behavior in Jupyter classic, enabled by a hack in the classic notebook. B is the behavior we moved to in JupyterLab (as "cleaner" behavior). We actually moved classic to B (I think in ipywidgets 7), but then re-enabled the hack later.

The problem is actually a more general problem than widgets - it's what to do about output stemming from a comm message, where there may not be any clear place to put the output (for example, what if a widget model, not associated with a cell, sends a message?). See jupyterlab/jupyterlab#1254 for more context, and in particular the TODO items for a way to deal with the problem. The basic idea is to have a notebook-level output place for messages that don't neatly fall into a single cell.

@SylvainCorlay
Copy link
Member

SylvainCorlay commented Apr 19, 2019

The question is more about where output should be displayed.

In the screencast below, we show that in the case of the classic notebook, streams are redirected to the cell where the action originated.

slider

However, for other widget messages that don't originate from a specific view (e.g. with a webcam widget that would capture the webcam input), where should the message be displayed? The reasoning with jupyterlab is that this new behavior was more 'consistent', but it turned out to be less intuitive to users.

@SylvainCorlay
Copy link
Member

My opinion is that all jupyter frontends should have a "debug" output area (not necessarily visible by default) that would show all output and error messages that don't have a parent header.

@williamstein
Copy link
Contributor

The basic idea is to have a notebook-level output place for messages that don't neatly fall into a single cell.

Cool -- your option C, namely a debug or log page, makes good sense and solves some problems I had not anticipated. Thanks!

@jasongrout
Copy link
Member

And the thought was that once we have a notebook-level place for output messages in JupyterLab, it will be intuitive again. For now, we suggest that people use an output widget to capture errors: https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html#Debugging-errors-in-callbacks-with-the-output-widget

@jasongrout
Copy link
Member

@jasongrout
Copy link
Member

Closing as answered (but feel free to post here if we need to continue the discussion)

@jasongrout jasongrout added this to the Reference milestone Apr 20, 2019
@lock lock bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label May 21, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

4 participants