You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our extensions often retrieve sessions with some given metadata. Currently, each extension maintains a list of its known sessions to facilitate this. This is unnecessarily verbose and error-prone. We should instead consider expanding the API to streamline this.
Here's why we currently retrieve sessions across our extensions:
Get the session corresponding to a given notebook URI.
Get the most recently created R console session that is not uninitialized or exited.
Check if a Python session exists with a given interpreter path.
Get the Python session with a given interpreter path.
Each of these ultimately filters the entire list of running sessions based on session metadata or session state (note that a session's state is not currently exposed in the API).
Proposal:
Expose positron.runtime.getSessions(), returning all running sessions i.e. the union of values of the _consoleSessionsByLanguageId and _notebookSessionsByNotebookUri maps, and let callers do their own filtering.
I'm not sure if there are performance concerns around sending the entire list of sessions on each call rather than adding filtering args to the function but from my understanding it should not be a problem.
Callers can also use getSessions() to check for the existence of a session with the given properties, rather than additionally exposing hasXSession() functions too. From my understanding, this also wouldn't be a performance concern.
For retrievals which are meaningful across extensions, expose more specific functions to ensure that all extensions use the same semantics e.g. getConsoleSession(languageId) (to be used in Positron R here). There's already a IRuntimeSessionService.getConsoleSessionForLanguage that we could wire this up to.
Add a readonly state property to ILanguageRuntimeSession so that callers can filter on runtime session state too.
The text was updated successfully, but these errors were encountered:
I like this proposal. The fact that the same internal session management tools have sprung up in multiple extensions signals that there's a need for this.
I'm not sure if there are performance concerns around sending the entire list of sessions
Definitely not. The set of sessions is never going to be large; even a complicated workspace with a bunch of notebooks open and interpreters running would be unlikely to exceed a dozen.
One thing to remember (especially for the R case and likely for other language packs) is that it's not enough to return a Positron session -- the extensions need to get the exact session object they registered, e.g. not an ILanguageRuntimeSession but specifically an RSession because we are retrieving the R session in order to do something R specific with it that isn't part of the lowest-common-denominator session interface.
Our extensions often retrieve sessions with some given metadata. Currently, each extension maintains a list of its known sessions to facilitate this. This is unnecessarily verbose and error-prone. We should instead consider expanding the API to streamline this.
Here's why we currently retrieve sessions across our extensions:
Each of these ultimately filters the entire list of running sessions based on session metadata or session state (note that a session's state is not currently exposed in the API).
Proposal:
Expose
positron.runtime.getSessions()
, returning all running sessions i.e. the union of values of the_consoleSessionsByLanguageId
and_notebookSessionsByNotebookUri
maps, and let callers do their own filtering.I'm not sure if there are performance concerns around sending the entire list of sessions on each call rather than adding filtering args to the function but from my understanding it should not be a problem.
Callers can also use
getSessions()
to check for the existence of a session with the given properties, rather than additionally exposinghasXSession()
functions too. From my understanding, this also wouldn't be a performance concern.For retrievals which are meaningful across extensions, expose more specific functions to ensure that all extensions use the same semantics e.g.
getConsoleSession(languageId)
(to be used in Positron R here). There's already aIRuntimeSessionService.getConsoleSessionForLanguage
that we could wire this up to.Add a readonly
state
property toILanguageRuntimeSession
so that callers can filter on runtime session state too.The text was updated successfully, but these errors were encountered: