notebook
notebook copied to clipboard
Output cells should not auto-collapse more than once per execution
Description
I just upgraded to jupyter notebook 7.0, thus migrating from the "classic" experience to the "jupyterlab" based version. With that migration, my user-experience has degraded significantly. I have a notebook that hosts a number of weakly related interactive tasks that I run sporadically while exploring a problem. The output from some of these cells can sometimes be 100s of lines long. In general, that output being collapsed is great, but while a specific task is running, I want to be able to use the full screen real-estate to monitor the (long-running) task as it goes. Previously, I would un-collapse the output after it started, and then be able to just follow the output, as it is generated. Now, if I attempt to do that, after a several seconds and potentially hundreds of lines of output later, it auto-collapses again. All of a sudden, this leaves me (who followed the output in the uncollapsed state) in the middle of nowhere far away in that document. It appears, previously (Notebook v 6.x), it would only auto-collapse once per execution, but now it does it repeatedly.
(I have been directed here from the JupyterLab repo, where I reported the same issue: https://github.com/jupyterlab/jupyterlab/issues/11760 )
Reproduce
- Execute a cell containing long-running code that continuously produces output, such as the following:
import time
for k in range(10):
print("\n".join(f"- {k}.{v}" for v in range(100 if not k else 20)))
time.sleep(5)
- Try keep the output area expanded and follow the output at it generates. It will constantly collapse away under your nose. If there is a lot of cells/output following the currently executing cell, you'll have a hard time getting back to that output.
Expected behavior
The output area should stay uncollapsed while I'm following the output.
Context
- Operating System and version: macOS 13.4
- Browser and version: Chome Version 115.0.5790.114 (Official Build) (arm64)
- Jupyter Notebook version: 7.0.2
Screencast
Both examples show the same notebook executed in two different versions of jupyter notebook.
I have added one cell above and below each containing dummy output ((pre-fill) and (post-fill)) to highlight the user experience if that happens in the middle of a long notebook.
Version 7.0.2
https://github.com/jupyter/notebook/assets/1310437/c1efb6d1-bff0-4991-b353-bad2a1bda4f5
Version 6.5.5
https://github.com/jupyter/notebook/assets/1310437/9ea55510-e027-4681-aa38-d492b854c3db
Thanks @burnpanck for reporting :+1:
(I have been directed here from the JupyterLab repo, where I reported the same issue: jupyterlab/jupyterlab#11760 )
Thanks! The implementation in Notebook 7 is a bit clunky at the moment and was added here only to mimic the behavior of the classic notebook. For reference the code is available here:
https://github.com/jupyter/notebook/blob/b5133c67f1a5c9c87d99abc44b7b04e6214aca45/packages/notebook-extension/src/index.ts#L290-L375
Ideally a more robust (and configurable) implementation will be implemented in JupyterLab first (as part of https://github.com/jupyterlab/jupyterlab/issues/11760) so it can be reused in Notebook 7 directly.
I'm not sure how this worked in the notebook versions < 7, but I actually had trouble reproducing the auto-collapsing behaviour for the video above after I had tested it before screen-recoding. Maybe it has nothing to do with "once per execution", but rather that with notebook < 7, expanding the collapsed output would set the scroll-mode explicitly, which would then prevent any auto-scroll:
https://github.com/jupyter/notebook/blob/b5133c67f1a5c9c87d99abc44b7b04e6214aca45/packages/notebook-extension/src/index.ts#L315-L319
So then, the difference in the user-experience really would come from the fact that the new notebook doesn't set that scrolled metadata when the user undoes the auto-scroll, or at least not in a way for the above code to notice.
Ideally a more robust (and configurable) implementation will be implemented in JupyterLab first (as part of https://github.com/jupyterlab/jupyterlab/issues/11760) so it can be reused in Notebook 7 directly.
I fear this is going to take some time. Given that the current auto-collapse behaviour is extremely disruptive to some workflows, is there a workaround available, e.g. just completely disabling that behaviour?
I'm not sure how this worked in the notebook versions < 7
The classic notebook also had some arbitrary thresholds:
https://github.com/jupyter/notebook/blob/a9a31c096eeffe1bff4e9164c6a0442e0e13cdb3/notebook/static/notebook/js/outputarea.js#L96-L120
just completely disabling that behaviour
Sure. You can disable the corresponding plugin:
jupyter labextension disable @jupyter-notebook/notebook-extension:scroll-output
For those who end up here because they want to completely deactivate the auto-scroll behavior. Go to "Setting" > "Settings Editor" > "Jupyter Notebook Notebook" and uncheck "Auto Scroll Outputs".
Note, the menu item "Settings Editor" is not available in the notebook view, only in the file browser.