Skip to content

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

Open

Description

@musically-ut

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?

Activity

  1. added this to the not ipython milestone on Jan 19, 2017
  2. takluyver commented on Jan 19, 2017

    @takluyver
    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.

  3. musically-ut commented on Jan 19, 2017

    @musically-ut
    ContributorAuthor

    @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!

  4. takluyver commented on Jan 20, 2017

    @takluyver
    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.

  5. musically-ut commented on Jan 20, 2017

    @musically-ut
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions