Blocking cell execution waiting for Widget interaction
- Vorherrschende Sprache
- Python
- Sterne
- 734
- Forks
- 412
- Ø Merge
- 1 T. 5 Std.
- Gemergte PRs (30 T.)
- 8
Beschreibung
Hi all,
I am interested in blocking further cell execution in a Jupyter notebook until some sort of widget interaction has occurred. For instance, letting a user perform a "cell -> run all" command, then displaying a dropdown widget in one cell, and blocking in the next cell until the user has selected an option from that dropdown list.
In a regular notebook setup, widget changes (`comm_msg` over zeromq) won't be picked up by the kernel because it's blocking until the cell is completely executed. If an [Asynchronous Loop](https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Asynchronous.html) is involved, then all cells will be executed (from the "cell -> run all") command immediately if they aren't written in an async fashion.
One option is to override the `kernel.shell_handlers` functions to 'capture' the `execute_request` messages coming in on the stream while letting the `comm_msg` events go through, then to 'replay' the `execute_request` messages after the fact. If I go with that pattern ([example](https://github.com/kafonek/widget_demos/blob/master/captured%20kernel%20events.ipynb), how do I make the output show up in the output cells for the original input cells instead of all in a single cell where the 'replay' happens?
A second option is to have the `ipykernel` listen for `execute_request` and `comm_*` events on different streams. There's been discussion of that idea (@dsblank @AlexTugarev https://github.com/ipython/ipykernel/issues/65, @jasongrout https://github.com/jupyter/jupyter_client/issues/285), but it doesn't look like the issue has moved forward. I don't understand the entire front-end/back-end system to know how significant that change would be. Is this issue a non-starter (https://github.com/ipython/ipykernel/pull/302)?
Thanks.
Beitragsleitfaden
Rechercherichtung
Start by reading the referenced asynchronous-loop example, the kernel.shell_handlers entry point, and the discussions in ipykernel issue 65 and jupyter_client issue 285. Compare the proposed execute_request and comm_* handling approaches, including PR 302, and establish whether blocking execution while preserving output in the original cells is feasible.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- jupyter, python
- Bereich
- api, backend, distributed-systems
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100