-
Notifications
You must be signed in to change notification settings - Fork 293
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
Adopt new Python extensions non-blocking API for interpreter disocvery #7583
Comments
@karrtikr just want to double check, this new API won't break existing users, right? If a user is on python insiders, but not updating the jupyter extension, they won't be broken because the old extension is still using the old API? |
Yes, the old APIs are still available, the new APIs are added in addition. |
FYI we plan to expose discovery API generally for all extensions and not just Jupyter, and it's a little different from this API. Proposed design: https://gist.github.com/karthiknadig/4b7bc9a9420e9071105007b5cc096f65 I'll leave it up-to you guys on whether you want to wait for the final general API. This issue can be closed in that case. |
@karrtikr Was looking at this API today, some questions:
Here's the code that shows the objets are re-created everytime for every event this.changed.fire({
type: event.type,
new: event.new ? convertEnvInfo(event.new) : undefined,
old: event.old ? convertEnvInfo(event.old) : undefined,
resource: event.searchLocation,
}); Internally things are ok for Python extension as the original object refs are stored and updated in place } else if (seen[event.index] !== undefined) {
const oldEnv = seen[event.index];
seen[event.index] = event.update;
didUpdate.fire({ index: event.index, old: oldEnv, update: event.update }); Solution
|
You could compare the
We maybe doing this but we do not rely on this information and do path check directly, see here: https://github.com/microsoft/vscode-python/blob/ec628195910d7b67fba12ece521d60b75a81fb0f/src/client/pythonEnvironments/base/info/env.ts#L245-L247 |
That wouldn't work as some conda environments. If you create conda environments on unix, the python path is the same as the base conda env.( Unless you provide the python argument in the clip). |
Interesting, we're not handling such environments at the moment in the discovery component and completely rely on 'path', but weirdly haven't received any issue reports. |
Closing this as completed, the new API has been completely adopted. |
Can we consider microsoft/vscode-python#19989 as unblocked from Jupyter's end, if there's no feedback/concerns? |
Can we leave the Python issue opeen at least for one iteration, in case we run into any issues, this was we have a chance to test the API in production. Note: That doesn't mean that there are any issues, but would prefer to leave the Python issue open for now. Next month if we dont get back, then please feel free to close it. |
Makes sense, not a problem. |
Three discovery APIs are being added for Jupyter which is meant to replace existing
getInterpreters()
API: microsoft/vscode-python#17452Previous behavior:
Existing
getInterpreters()
is an asynchronus blocking API, so it waits until all of discovery is completed the first time it is called. Subsequent calls return instantaneously from cache if the same resource is queried again.New behavior:
getKnownInterpreters()
simply returns whatever is currently in cache. It is useful when we do not need all of the interpreters at once, which is usually the case. In the Python extension we are able to replace all instances ofgetInterpreters()
withgetKnownInterpreters()
. Do note that the kind info returned by this API may change as refresh progresses.onDidChangeInterpreters
fires when an environment gets added/removed/updated in cache. Event properties tracks the old and new environments accordingly.refreshPromise
is set. It can be used to implement now deprecatedgetInterpreters()
in the following way:getInterpreterDetails()
is still available as before, and can be used to get complete and reliable information on environments. As it is a blocking call, it's recommend to only use it if complete information is needed, which is generally only the case for selected interpreters.You can the see the new API in action here in our dynamic quickpick microsoft/vscode-python#17043 (comment).
Changes regarding quickpick API
We also used to expose
getSuggestions
API for the quickpick, which has the same problem asgetInterpreters()
. The following non-blocking API is being added to replace it:It can be used in combination of
refreshPromise
to get all suggestions. Let me know if you have any questions! 😄The text was updated successfully, but these errors were encountered: