Skip to content

Allow extensions to call cell commands with cell arguments #98282

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

Closed
DonJayamanne opened this issue May 20, 2020 · 7 comments
Closed

Allow extensions to call cell commands with cell arguments #98282

DonJayamanne opened this issue May 20, 2020 · 7 comments
Assignees
Labels
api feature-request Request for new features or functionality notebook
Milestone

Comments

@DonJayamanne
Copy link
Contributor

In the Python notebook we have commands to run

  • Current cell and all below
  • All cells above current cell

This is also available in Jupter.
We can add our own commands and icons for this, however there's no way to allow user to cancel the execution.
Today when user runs a cell, they get an individual cancel against each cell, if they run all cells they get a cancel button on the top.

If we (python extension) added our own commands to run the cells, then we'd need our own cancellation icon and I think this would be inconsistent with the current VS Code UI.

Providing at a minimum the VS Code commands such as notebook.cell.executeAllBelow & notebook.cellexecuteAllAbove and allowing extension authors to execute these would be awesome.

@rebornix /cc

@vscodebot
Copy link

vscodebot bot commented May 20, 2020

@rebornix rebornix added the feature-request Request for new features or functionality label May 20, 2020
@roblourens
Copy link
Member

We can add these. Yeah it's not currently possible for an extension to implement it, but it should be.

Do you think that instead of using a CancellationToken for cancel, we should have a cancelCell API next to executeCell? That would make this more natural where the extension has declared that a cell is executing, but executeCell has not been called so there is no token available.

Or, the extension could just use executeCommand with the cell execution command ID.

@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented May 26, 2020

Or, the extension could just use executeCommand with the cell execution command ID.

Yes, this works perfectly well for us.
This would allow extension authors to execute arbitrary cells, and allow users to cancel execution using the built cancel buttons (next to the cell).

This way we can handle execute cells and below, however the assumption is VS Code would display the cancel buttons next to the cells.

@roblourens
Copy link
Member

I think it might be hard for us to implement this, for the same reason that we don't implement "execute notebook" by executing cell individually, but tell the notebook to execute the full notebook. We don't know whether cells can be run in parallel, or whether there's a certain order or other requirements. So I don't know whether it would be unhelpful to add a command that does this out of the box. Will think about it more.

Actually I think we need an API that can execute N particular cells. We might support multiselect and then I will want to tell the extension to execute all selected cells. So we can solve this just by making the execute callback take an array of cells

@rebornix
Copy link
Member

  • 1 for supporting multiple selections for cell execution
-executeCell(document: NotebookDocument, cell: NotebookCell, token: CancellationToken): Promise<void>;
+executeCell(document: NotebookDocument, cells: NotebookCell[], token: CancellationToken): Promise<void>;

and the same token can be used to cancel the execution. Also if the execution involves multiple cells, we may want to show a cancel button on the editor toolbar to cancel the button.

@roblourens roblourens modified the milestones: June 2020, July 2020 Jun 30, 2020
@roblourens roblourens changed the title Add commands to run current & below or run all above cells Allow extensions to call cell commands with cell arguments Jul 16, 2020
@roblourens roblourens modified the milestones: July 2020, August 2020 Aug 3, 2020
@roblourens roblourens modified the milestones: August 2020, Backlog Aug 29, 2020
@jrieken jrieken added the api label Sep 15, 2020
@DonJayamanne
Copy link
Contributor Author

No longer required.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api feature-request Request for new features or functionality notebook
Projects
None yet
Development

No branches or pull requests

6 participants
@roblourens @rebornix @jrieken @DonJayamanne and others