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

Output of %%time is irretrievable when connection to notebook is lost. #10064

Open
musically-ut opened this issue Nov 24, 2016 · 4 comments
Open
Milestone

Comments

@musically-ut
Copy link
Contributor

If I start a long running cell on a notebook which has the %%time magic as the first line and then accidentally lose connection to it (dropped SSH, or closing the browser window), the output (i.e. the running time of the statements) is lost.

Is it possible to show the output of the %%time command on the kernel's console on the server in such cases?

I've encountered some optimization routines (e.g. L-BFGS from scipy.optimise), which output solely on the kernel console. So that makes me think that there is a way to output to the kernel's stdout at least via C. Is there a better and/or documented way of outputting on the kernel's console?

If so, I am willing to write an extension for my own use which extends %%time magic.

Also, looking at the code for the magics,, there are thresholds in place which determine whether the Parse Time and Compile time are shown to the user ( (tp_min and tc_min respectively). Perhaps there could be a similar threshold which could push the output to the kernel console if the process runs for long enough that the connection may be dropped?

@takluyver takluyver added this to the not ipython milestone Jan 19, 2017
@takluyver
Copy link
Member

We do plan to fix this in the notebook so that changes show up in the notebook even if you close the browser tab (or lose the connection to the notebook server). But it requires some substantial architectural changes, to store the state of the document on the server.

We don't generally fall back to showing things on the kernel console, which may not be accessible to the user, and isn't an obvious place to look for output.

@musically-ut
Copy link
Contributor Author

@takluyver Thanks for the feedback.

I understand that this is not the best solution. However, it would solve my problem and I am interested in writing an extension which can do this as a make shift arrangement till the architecture is overhauled.

Could you give me a few hints as to how one may try to do it if one were so inclined?

Thanks!

@takluyver
Copy link
Member

The kernel doesn't have a good way of knowing when the notebook is connected, but any output you print to sys.__stdout__ (with the double underscores around stdout) should end up in the terminal if you want to play around.

@musically-ut
Copy link
Contributor Author

Perfect! That was the ingredient I was missing. Thanks!

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

No branches or pull requests

2 participants