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

Proposal: Streamline code execution via the extension API #2622

Open
seeM opened this issue Apr 3, 2024 · 2 comments
Open

Proposal: Streamline code execution via the extension API #2622

seeM opened this issue Apr 3, 2024 · 2 comments
Labels
area: api Issues related to API category.

Comments

@seeM
Copy link
Contributor

seeM commented Apr 3, 2024

The current positron.runtime.executeCode function resolves when the code is sent to the runtime. However, in both the Positron R and Positron Notebook Controller extensions we construct a promise that resolves when the code is handled by the runtime (by waiting for the status idle message), or rejects after a timeout.

The latter seems much more useful for language packs and other extensions so possibly worth streamlining.

Proposal:

Update positron.runtime.executeCode to:

  1. Resolve when the session receives a status idle message.
  2. Reject after a configurable timeout.
  3. Accept a callback: (message) => void that is called on each received runtime message with the same parent ID as the execution ID.
@seeM seeM added the area: api Issues related to API category. label Apr 3, 2024
@seeM seeM assigned seeM and unassigned seeM Apr 3, 2024
@jmcphers
Copy link
Collaborator

jmcphers commented Apr 5, 2024

This functionality was frequently requested by the team developing the R extension, though we never got around to implementing it. I bet other extension authors would also find it very beneficial.

I think it would also be important for the promise to reject if the code causes an error to occur, as an important use case (for R) was running some code on the user's behalf and knowing both (a) whether it finished, and (b) whether it ran successfully. There are also other rejection cases, such as the runtime exited/being shut down/restarted/interrupted during execution.

We could probably leave it up to the caller to wrap the promise in a timeout if needed.

@seeM
Copy link
Contributor Author

seeM commented Oct 10, 2024

There's an initial attempt at this in the positron-notebook-controllers extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API category.
Projects
None yet
Development

No branches or pull requests

2 participants