-
Notifications
You must be signed in to change notification settings - Fork 101
Add new command to kick off (refresh) interpreter discovery #7762
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
Conversation
E2E Tests 🚀 |
constructor() { | ||
super({ | ||
id: LANGUAGE_RUNTIME_DISCOVER_RUNTIMES_ID, | ||
title: nls.localize2('workbench.action.language.runtime.discoverAllRuntimes', "Discover All Interpreters"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use wording here that is more like "Refresh Interpreter Discovery", if we think that is better or more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the wording in the PR!
src/vs/workbench/services/runtimeStartup/common/runtimeStartup.ts
Outdated
Show resolved
Hide resolved
constructor() { | ||
super({ | ||
id: LANGUAGE_RUNTIME_DISCOVER_RUNTIMES_ID, | ||
title: nls.localize2('workbench.action.language.runtime.discoverAllRuntimes', "Discover All Interpreters"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the wording in the PR!
* enters the discovery phase, in which each extension is asked to supply | ||
* its language runtime metadata. | ||
*/ | ||
public async discoverAllRuntimes(): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a couple of changes if it is going to be public:
- we need to validate that the startup phase we're currently in is compatible with a transition into Discovering to make sure this can't accidentally get called when a discovery is already in flight, and/or get accidentally invoked before we get to the first discovery phase
- the contents of
_discoveryCompleteByExtHostId
need to be correct going into this method (i.e. false for all ext hosts since we are about to do discovery) so we should set or enforce that -- otherwise we'll never enter (or will prematurely enter) the complete state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the original one back to be private and made a new public rediscoverAllRuntimes()
that will only run when we have gotten all the way to Complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. A nice future improvement would be for this to show a progress dialog and summarize its work when it's done ("discovering" .... "found 2 new interpreters: interpreter a, interpreter b") since right now it can feel like the command didn't do anything.
I was thinking the same thing ("this doesn't seem like it's doing anything") so I added a notification in d00af25. This is still just for adding new runtimes. I was playing around with this more, and I am realizing it doesn't work very well (at all???) for Python, but I think it's something in the Python extension going wrong. For example, if I:
If I reload the whole app, then I do see the new pyenv Python show up. @isabelizimm does this ring a bell for you? I know you were looking at some of this a while back. What might be causing the "Refresh interpreter list" button not to be working? And then subsequently the Positron-specific discovery not to be working? |
Was this using the native or js locator? I am seeing the new version show up for both locators when you click the refresh button; the new Python ends up in its own section below It's possible to have a refresh query only for certain Python paths, although functionally I'm not quite sure how you'd get into that situation on accident. |
I think something might be going on around here: positron/src/vs/workbench/services/runtimeStartup/common/runtimeStartup.ts Lines 788 to 791 in 0ff52df
These are actually the runtime managers per extension host, not per extension. How things are turning out for me right now has both R and Python in one extension host. IIUC that means this is being run one time per extension host (not per extension): positron/src/vs/workbench/api/browser/positron/mainThreadLanguageRuntime.ts Lines 1417 to 1419 in 0ff52df
|
Signed-off-by: Julia Silge <[email protected]>
@@ -48,6 +48,7 @@ export async function* pythonRuntimeDiscoverer( | |||
traceInfo(`pythonRuntimeDiscoverer: recommended interpreter: ${recommendedInterpreter?.path}`); | |||
|
|||
// Discover Python interpreters | |||
await interpreterService.triggerRefresh().ignoreErrors(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what we needed for this to work for Python! 🎉
However, it does change what the Python discoverer does for all uses. Do we think this is a good way to go? The alternative is that discoverAllRuntimes()
on the runtime startup service could gain an optional boolean argument that specifies whether this is a refresh or an original discovery; we would then pipe it through the API command through to here:
return this.discoverPythonRuntimes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refreshing every time could slow down discovery if users open up multiple windows, since it runs on extension activation. However, finding interpreters each new window might be a nice experience (and actually make it less necessary to use a refresh command). I think its fine to do every time.
Addresses #4269
This PR adds a new command
workbench.action.language.runtime.discoverAllRuntimes
to kick off runtime discovery. I just have it accessible from the command palette (no keybindings, no UI), which is a good option for now, I think. I put this in with other commands inlanguageRuntimeActions.ts
, although I do want to highlight that all the other commands in there apply to a single interpreter, not to all of them as a whole.This command can only add new interpreters. If the user removes an interpreter while Positron is running, this new command does not get rid of it because the runtime is still registered; discovery can only add runtimes. We could totally clear all the registered runtimes but that seems pretty destructive, and removing runtimes hasn't been a big concern so far. Thoughts?
Release Notes
New Features
Bug Fixes
QA Notes
I think the easiest way to see if this is doing what we expect is to watch the output channel for either the R or Python Language Pack and execute the command. You'll see all the logging for interpreter discovery go by each time you do so. Alternatively, you could: