microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.07k stars 29.21k forks source link

Command to "Run cells in section" for current cell's section in notebook. #209653

Open asford opened 7 months ago

asford commented 7 months ago

Searched for "Run cells in section", had filed as https://github.com/microsoft/vscode-jupyter/issues/15501, maybe it belongs here.

The new "Run cells in section" feature is fantastic for organizing notebooks, particularly where you may have a section of "heavy IO" before a block of EDA or interactive analysis.

We often have notebooks with two sections:

  1. A "data load" block that loads data from a backend warehouse, potentially running some expensive post-processing.
  2. A "analysis" block, where we reshape the data, define some helper functions and run some lighter post-processing or tidy the dataset.

The "run in section" feature is great inside an analysis block, because we can easily rerun the lightweight helper definitions and generate EDA plots without triggering the heavier IO section of the notebook. Wow! Much rapid feedback. Much workflow ease. Nice.

However, unlike the (also great) "Run Precedent Cells" feature, there doesn't appear to be a way to trigger this from the command palette (and therefor keyboard shortcut) for the selected cell or section.

It would be good to add a editor command "Execute Section Cells"...

...selectable by the standard command palette ...targetable by keyboard shortcuts ...(ideally) in the extended run dropdown

...that detects the section of the currently selected cell or cells ...then runs the entire section (or sections) in the needful way (as if I clicked this on the section header in outline)

Examples of where in the UI I would expect this to show up... image image

I noted, in the keyboard shortcuts section, notebook.section.runCells, however this doesn't appear to have an effect when bound to a key.

amunger commented 6 months ago

Doesn't jupyter.runcurrentcell do this? The command name doesn't suggest it, but when I press ctrl+enter or shift+enter with multiple cells selected, those cells are run.

asford commented 6 months ago

Yes, you're correct that that command has those semantics and runs multiple selected cells.

The specific ask here is to lift the "run cells in section" command, which is currently only exposed as a dropdown from the outline view.

image

In to a command that will (conceptually):

I think this is probably equivalent to adding a command that will:

vscodenpa commented 6 months ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

dbwtx commented 2 months ago

Is there any update to this? It would be very convienent to be able to map a keyboard shortcut to this functionality, and it is odd that the notebook.section.runCells shortcut doesn't work, even though the name implies it would do this desired function.