Skip to content

Enable showing notebook stdout/stderr output when executing #2212

Open
@ctcjab

Description

@ctcjab

When nbconvert executes a notebook that writes to stdout/stderr, the notebook's output is swallowed, and there is currently no way to opt in to showing the notebooks's output. This is particularly an issue for notebooks whose output you need to monitor closely while they execute, and especially when such notebooks take a long time to execute -- not seeing any output of such notebooks makes it impossible to tell what they're doing and is indistinguishable from a notebook that is hanging doing nothing.

Putting this example code in a notebook can be used to demonstrate this:

import time
for i in range(3, 0, -1):
    print(f"sleeping {i}...")
    time.sleep(1)
print("woke up")
time jupyter nbconvert tmp.ipynb --to html --execute  # hangs silently while the notebook is executing
[NbConvertApp] Converting notebook tmp.ipynb to html
[NbConvertApp] Writing 271904 bytes to tmp.html

________________________________________________________
Executed in    5.51 secs    fish           external
   usr time    1.78 secs    3.10 millis    1.77 secs
   sys time    0.24 secs    3.02 millis    0.23 secs

Instead, there should be a way to get something more like this:

time papermill --cwd=. --log-output /tmp/tmp.ipynb /tmp/tmp.ipynb
Input Notebook:  /tmp/tmp.ipynb
Output Notebook: /tmp/tmp.ipynb
Working directory: .
Executing notebook with kernel: python3
Executing Cell 1---------------------------------------
sleeping 3...

sleeping 2...

sleeping 1...

woke up

Ending Cell 1------------------------------------------

real    0m4.497s
user    0m0.892s
sys     0m0.183s

Note this affects not only nbconvert users, but also users of [projects that are downstream of nbconvert, such as jupytext. See here for example.

Would you be open to adding support for showing notebooks' output while executing?

Thanks for your consideration and for maintaining nbconvert!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions