-
Notifications
You must be signed in to change notification settings - Fork 294
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
Add "Restart and run all" command #9242
Comments
After discussion and some analysis of other notebook implementations, it's not clear that just replacing "run all" with "restart and run all" is prudent. Instead, it seemed to be safer to simply add a way to accomplish this behavior in addition to the existing run-all via something like adding a new command in in the jupyter-extension that could be bound to a keystroke. |
I have just started using VSCode and I like it a lot, but I agree that this is a problem. I come from using Jupyter Notebooks in an ordinary Google Chrome browser for Python development, so it is quite odd to only have the few buttons available in VSCode. My workflow when doing R&D is often that I will change some parameters in a Notebook cell, and then re-run everything from that cell and below, so all the experiments are re-run with the new parameters, but there's no need to re-load data-files etc in the cells above. But sometimes I like to restart the kernel and re-run the entire Notebook, just to make sure that I don't have old variables or function definitions lingering somewhere in the background. Perhaps an idea is to make the Jupyter run-buttons customizable, so the user can decide which buttons to show in the menu-bar at the top of the Notebook editor? Thanks! |
I support the idea to add a "Restart Kernel and Run all" command or/and button. Also, I think it would be confusing to use the current "Run all" button to perform this behavior. |
There haven't been any up votes on this issue hence closing this for now |
I'm also interested just forgot to upvote D: |
I would also like to see a "restart and run all" button, it is a big part of my workflow |
Please do upvote the above issue, thats how we gauge interest in feature requests |
@DonJayamanne by upvote, do you mean giving a 👍 to the original post? |
I'd like to 👍 for this feature request because I usually get confused if the error/warnings are from a current/previous run. I do end up selecting |
I can't believe this still isn't a feature |
As soon as this PR (microsoft/vscode#177722) lands in the mainline of VSCode, you can just add this to keybinding.json. { // Restart and run all cells in Jupyter notebook
"key": "alt+shift+r",
"command": "runCommands",
"args": {
"commands": [
"notebook.clearAllCellsOutputs",
"jupyter.notebookeditor.restartkernel",
"notebook.execute"
]
},
"when": "notebookEditorFocused"
}, |
Just wanted to update people that this command is now released within VS code insiders via the daily pre-release of the jupyter extension. It will also be available at the next monthly stable release. The command is available via the command palette. The command name is: |
Replacing the "Run All" button is not necessary. It is possible to add another button "Restart and Run All" |
To clarify, the current toolbar button for |
Thanks for adding this feature - but I really need the menu-button! :-) It would also be practical if I could configure what exactly it does: I would like it to do a "Clear All" as well, but others may not like that. Then I would probably remove the "Run All" button from my menu-bar as I don't need it anymore. Thanks! |
FYI restart action name changed to "jupyter.restartkernel" |
@nikitakuklev it took me some time to find your comment and figure out why my restart keybinding wasn't working anymore. Is there a place where all the possible commands are listed that I'm not aware of? Seems like an extremely simple and useful thing to have in the Readme... |
@atticusmatticus If you use the command palette ( |
To get the actual command name, I looked at the package.json file. Not sure if extensions must declare all commands there, but seems to work for a few common ones. |
@nikitakuklev & @atticusmatticus |
Discussed in #9217
Originally posted by benlindsay March 3, 2022
In the Jupyter toolbar, there's a Run All button
which looks a lot like the Restart and Run All button in Jupyter Lab
My initial expectation was that those buttons would be analogous, but in VSCode, it does not restart the kernel or clear outputs. Having that button fail to clear outputs is harmful because state from the previous run can be reused. For example, say you have a notebook with 2 cells:
and
If you run just the second cell, then click "Run All", your notebook will not fail even though it should. I can't think of any reason someone should want to rerun a notebook without also restarting the kernel. As for the clearing outputs bit, there is a case to be made for not clearing outputs, because it can be nice to see what was previously there. However, 2 points in favor of clearing outputs are 1) it would match behavior expectations from Jupyter Lab, and 2) when outputs are cleared prior to rerunning, it's much easier to tell where a failure occurred when scrolling through the notebook. Harder to tell when old outputs remain.
I hacked together a solution by adding a multicommand keybinding to keybindings.json, but that really shouldn't be necessary for a critical functionality. My keybinding looks like this:
Thanks for all of y'all's work on this project!
The text was updated successfully, but these errors were encountered: