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

[feature request] add "Pause" button to Notebook #2363

Closed
andreas-h opened this issue Apr 4, 2017 · 30 comments
Closed

[feature request] add "Pause" button to Notebook #2363

andreas-h opened this issue Apr 4, 2017 · 30 comments

Comments

@andreas-h
Copy link

I was wondering if there is a way to pause/suspend a running Jupyter kernel from the Notebook interface? I was looking for a "Pause" button but couldn't find any.

Use case: Imagine you're working on a laptop, and have a long-running computation at work. Then it would be nice to suspend the kernel's activity when the battery gets drained.

@takluyver
Copy link
Member

Thanks for filing. I think this should be straightforward on Unix systems, using SIGSTOP (or SIGTSTP if we want to give the kernel the option to ignore it) and SIGCONT. These could be exposed as kernel actions in the REST API, like interrupt and restart already are. I don't know if Windows has an equivalent, but if someone builds a Unix-only solution and leaves the actions as no-ops on Windows, I don't think we'd hold it up.

@vidartf
Copy link
Contributor

vidartf commented Apr 5, 2017

@Madhu94
Copy link
Contributor

Madhu94 commented Oct 9, 2017

I ll check this out, if no one is working on it.

@takluyver
Copy link
Member

I don't think anyone is. The place to start will be in the jupyter_client package, adding API functions to pause and continue a kernel's execution.

@sunpope
Copy link

sunpope commented Feb 20, 2018

Hey, I see there hasn't been any update on this in a while. I've been checking out the jupyter_client package and working out where to add the API pause/continue functions. However, could anyone point me towards the right directory to go about adding a new button to the top bar of a notebook? I think the best way to do it is to have a separate button controlling SIGTSTP and SIGCONT and leave the current Run and Interrupt buttons as is.

@takluyver
Copy link
Member

I probably wouldn't put this in the toolbar for now: it's likely to be Unix only, and I'm not sure how reliably it will work. In terms of the UI, I'd probably start by making it an action (see actions.js) so that people can assign it custom shortcuts. But the APIs have to be built before anyone can add UI for it.

@sunpope
Copy link

sunpope commented Feb 27, 2018

Understandable, I'll go there and check it out. Is there a preference between having one action that both suspends the process if it is running AND continues the process if it has been suspended, or two separate actions to achieve the same thing?

@takluyver
Copy link
Member

It's not a strong preference, but I'd lean towards two separate actions. We can always add a separate toggle action afterwards.

@stas00
Copy link

stas00 commented Jun 16, 2018

Any updates on this one? @sunpope and @Madhu94 - has either of you made any progress on this?

arovit pushed a commit to arovit/notebook that referenced this issue Jul 5, 2018
@arovit
Copy link
Contributor

arovit commented Jul 6, 2018

Guys, I am working on this with PR 3739. Thanks.

@stas00
Copy link

stas00 commented Jul 6, 2018

@arovit, I tested #3739 with some pytorch/cuda long running code - seems to pause and resume just fine.

As far as usability goes, you probably don't need 2 buttons - one Pause/Resume toggle button should suffice as it'll mimic the hardware Play/Pause button we are so used to.

Plus, it would help to indicate somewhere at the menu level (always visible) that the execution thread is paused (perhaps in some color), (or perhaps the bg of the notebook itself change?), because I can see someone hitting the Pause button/menu item by mistake or on purpose and forgetting they did that, and then wonder why nothing works. Perhaps any attempts to execute cells while in that suspended mode should complain too, asking to resume first?

Thank you!

@arovit
Copy link
Contributor

arovit commented Jul 9, 2018

Thanks @stas00 for testing out and sharing this great feedback.
I agree with your suggestions (toggle button and some kind of notifier for kernel pausing) and will start making frontend changes. Right now, I am not 100% sure about what's the best/right thing to do when a user is trying to execute cells on a paused kernel, so for now I will keep this open ended while implementing first two.

@stas00
Copy link

stas00 commented Jul 9, 2018

I am not 100% sure about what's the best/right thing to do when a user is trying to execute cells on a paused kernel

I thought of changing the background of all cells to a different color indicating this different state. But then I remembered the themes extension, which would make this complicated, as unless that extension is brought in sync with such change, some color conflict may happen.

Probably, for now leaving the cells as they are is fine - as it is will just turn [*] waiting/busy flag on and perhaps, that'd be enough.

It'd be good to hear an opinion from the developers so that you don't waste time designing something that won't be accepted at the end.

Thank you for your work, Arovit.

@vinay9986
Copy link

@arovit: Thank you for the amazing contribution and @stas00: thank you for taking the time for testing the changes out.

@takluyver: Can you please tell us when can we have this feature rolled out?

@takluyver
Copy link
Member

We're on the cusp of releasing notebook 5.6, so I don't want to merge a new feature like this just before a release. After the release is done, hopefully quite soon.

@arovit
Copy link
Contributor

arovit commented Jul 21, 2018

Guys, I just updated the changes based on all the great feedbacks I received. Updates are to disable these options on Windows, toggle between pause and resume option and showing a notification for paused kernel in the notification bar. As always, looking forward to the feedbacks.

screen shot 2018-07-20 at 4 35 08 pm

screen shot 2018-07-20 at 4 36 11 pm

@stas00
Copy link

stas00 commented Jul 21, 2018

Verified it to work as discussed earlier. Thank you, @arovit!

wrt to placement - would it be functionally logical to put it next to Interrupt in the Kernel submenu?

Now, I've noticed that the Kernel sub-menu appears to be almost sorted alphabetically (but not exactly). So, perhaps, it's another reason to place it in 2nd place?

@arovit
Copy link
Contributor

arovit commented Aug 4, 2018

Thanks @stas00 . I just pushed a commit which adds a selenium testcase for testing this feature and also made changes to have pausing/resume options right next to Interrupt in the kernel submenu. Please let me know if there is anything else I need to work on. Thanks.

@arovit
Copy link
Contributor

arovit commented Oct 6, 2018

Hello, Gentle ping to get some traction on the PR. Thanks !

@ideascidata
Copy link

Just for reference, I found that if I wanted to pause the script running in Jupyter notebook and resume it later, CTRL+S ended up working well for me (although this must be performed in the Anaconda terminal).

Thanks

@githubpsyche
Copy link

just chiming to say i googled how to pause a notebook and ended up here! hope the feature's live sometime!

@MaxGhenis
Copy link

From the Linux shell, you can do Ctrl+Z to pause, then fg jupyter notebook to resume.

@vinay9986
Copy link

@arovit thank you for implementing the feedback.
@stas00 thank you for testing and sharing feedback.

@arovit I see that there is some merge conflict on your PR (on the test case), that is probably what is delaying your PR to be merged.

Eagerly waiting for this feature to be released.

@juliuskittler
Copy link

@arovit and @stas00 Thanks a lot for this feature! I was wondering if you are also planning to implement this for jupyter lab? On jupyter lab, there does not seem to be a Pause and Resume option. Thanks in advance for a quick reply!

Screen Shot 2019-05-11 at 19 31 34

@BlkPingu
Copy link

In which version of jupyter notebooks is this implemented? I just checked because I have this issue with a time consuming process and I would love to have this feature.
I'm in MacOS 10.14.5

@vidartf
Copy link
Contributor

vidartf commented Jun 18, 2019

This work is still WIP: #3739

@dbrucknr
Copy link

Hi everyone,

I'm seeking a project to contribute to for one of my college courses. I was curious if there is anything going on in this feature that I could help with? I use Anaconda/Jupyter all the time and would really appreciate the opportunity to give back.

@devanshgoenka97
Copy link

Is this still being worked on? If not I am happy to step in and contribute...

@dhivyasreedhar
Copy link

Hi, can I work on this? I'm new so can someone guide me?

@kevin-bates
Copy link
Member

Hi @dhivyasreedhar, We are primarily focused on bug fixes and security issues in the notebook repository right now, but appreciate your interest in helping. Resolution of this issue would likely require work in Jupyter Lab, Jupyter Server, and Jupyter Client although this does seem useful.

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

No branches or pull requests