'Reconnecting to jupyter ipynb (running) files
How can I run Jupyter notebooks disconnecting/reconnecting to its kernels without losing all the output from completed cells?
I know this has been asked several times and there are plenty of Q&A and web pages speaking about this, but I could not understand whether or not what I would like to do is possible and, if it is possible, what I am doing wrong. Many web pages and questions date back to several years ago, so, may be, such a basic functionality has been finally implemented.
I set up a remote jupyter using screen/tmux and ssh port forwarding. So I am able to connect to the remote machine using a web browser.
This is the notebook I run:
cell 1
import time
i = 0
while i < 10:
i += 1
print(i, flush=True)
time.sleep(5)
print("done")
cell 2:
print(i)
When I run the first cell, close the browser, reconnect to the kernel running the notebook above (Jupyter -> Running -> notebook) it seems that nothing is running. However, when I run the second cell, I realize the kernel is still running the first cell: there is no output for a while, then 10 is printed.
But:
- When I reopen the notebook, there is no indication about which cell is currently running;
- The output is lost. Not only the output produced after disconnecting from the kernel (closing the browser tab), but also all the output produced by the running cell between the
saveaction and the disconnection.
This makes Jupyter completely useless when running (long) notebooks whose output needs to be monitored every once in a while.
I have this question. Without using tricks (like capturing output with some magic, writing the output to external log files, running the notebook as a python script, ...), is it possible to configure jupyter in order to disconnect/reconnect from/to its kernels running ipynb files using only the web interface and keeping the output produced while no browsers were attached to it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
