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

Get output after closing and reopening the browser tab with notebook #12422

Closed
VladimirVisnovsky opened this issue Apr 15, 2022 · 9 comments
Closed

Comments

@VladimirVisnovsky
Copy link

Problem

I have a following situation. There is a multiple hour computation ran by Jupyter notebook. After the computation started I would like to close the tab. Then open the tab again (maybe on different device if the computation was run in the cloud) and check the output. But after I reopen the tab there is no output since the mappings between "Execution request" and the "Execution reply" are gone. There is a stackoverflow thread describing the problem in more precise way so I don't have to duplicate the concrete issue description.

Proposed Solution

What I would expect to see is that after starting of computation I would not have to keep my notebook opened in browser to keep the mappings between "Execution request" and the "Execution reply" alive. Instead I could close the tab and after multiple hours just return to the notebook for the output.

Could the notebook model be moved from client side to the server side? This way the mapping between "Execution request" and the "Execution reply" would not be lost and there would be no problem if one closed the tab, then reopened it and wanted to check the output.

Additional context

If I understand correctly this issue is known by the Jupyter team and I would like to get an update in case it has been forgotten since it would resolve my ongoing problem. Also I would appreciate some kind of workaround suggestion. I am printing everything twice into the standard output and into the log file (where I can tail the appending output real-time). But this is not a very elegant solution.

@welcome
Copy link

welcome bot commented Apr 15, 2022

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Apr 15, 2022
@JasonWeill
Copy link
Contributor

Elyra allows for the running of a notebook as a batch job, which may address the use case that you're describing:
https://elyra.readthedocs.io/en/latest/getting_started/overview.html#ability-to-run-a-notebook-python-or-r-script-as-a-batch-job

I don't see any other issues in JupyterLab to allow the server to both execute the code and modify the notebook, so that you can (for example) close the tab or open your notebook on a separate instance and see the results of long-running scripts. For this reason, I've accepted this issue.

@JasonWeill JasonWeill removed the status:Needs Triage Applied to new issues that need triage label Apr 21, 2022
@JasonWeill
Copy link
Contributor

As a workaround, you can run a computation and save the output to a variable. Then, if you close your browser tab and execution continues, you can come back, and the output should be accessible as a variable.

@chenmicheal
Copy link

Hi @jweill-aws , could you tell me how to save the output to a variable?
thank you in advance!

@JasonWeill
Copy link
Contributor

You can save the output by assigning it to a variable using standard Python syntax. If you still want to display it, you can refer to the variable on the next line.

For example, change

long_running_function(variables)

to:

myoutput = long_running_function(variables)
myoutput

@VladimirVisnovsky
Copy link
Author

Also @chenmicheal, take into consideration magic command %%capture which (quote from documentation) "runs the cell, capturing stdout, stderr, and IPython’s rich display() calls." With this magic command you can save all output of a cell into the variable in a native way for Jupyter notebook

Source:
https://ipython.readthedocs.io/en/stable/interactive/magics.html

Usage examples:
https://notebook.community/lifeinoppo/littlefishlet-scode/RES/REF/python_sourcecode/ipython-master/examples/IPython%20Kernel/Capturing%20Output

@chenmicheal
Copy link

thank you both very much!

@lumbric
Copy link

lumbric commented Aug 23, 2022

This is an often requested feature and discussed at many places. I want to add some links here, maybe it helps to find stuff.

Workarounds and explanation:

Other Github issues:

Zeppelin and Datalore have such a feature implemented.

A comment suggests that this issue might be related to RTC, but JupyterLab 3.4.4 does not support reconnecting after all browser tabs have been closed even with RTC enabled (just tested it).

@krassowski
Copy link
Member

Closing as a duplicate of #2833.

Of note there is now a PR implementing this: #15448

If I understand correctly this issue is known by the Jupyter team and I would like to get an update in case it has been forgotten since it would resolve my ongoing problem

Just FYI, Jupyter is open-source, community-driven everyone is welcome to contribute one way or the other. If you would would like to discuss a particular topic, weekly jupyterlab meetings may be suitable to get an informal answer but it is unlikely any one contributor would speak for the entire community on such high-level feature requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants