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

Respect python.defaultInterpreterPath setting #6281

Open
Tracked by #6202
seeM opened this issue Feb 11, 2025 · 1 comment
Open
Tracked by #6202

Respect python.defaultInterpreterPath setting #6281

seeM opened this issue Feb 11, 2025 · 1 comment
Assignees
Labels
area: runtimes Issues related to Language Runtimes enhancement New feature or request lang: python

Comments

@seeM
Copy link
Contributor

seeM commented Feb 11, 2025

We don't currently respect the python.defaultInterpreterPath setting (see upstream description):

  1. When initially selecting an interpreter for a session. This is particularly an issue in workspaceless sessions (see How to set a default kernel for jupyter notebook in Positron? #6244 (comment)).
  2. When changes are made at the user-scope (we could listen to the IInterpreterPathService.onDidChange event).

The logic for our initial interpreter selection is here:

let recommendedInterpreter = interpreterSelector.getRecommendedSuggestion(suggestions, workspaceUri)
?.interpreter;
if (!recommendedInterpreter) {
// fallback to active interpreter if we don't have a recommended interpreter
recommendedInterpreter = await interpreterService.getActiveInterpreter(workspaceUri);
}

We can get the value of the python.defaultInterpreterPath setting either from PythonSettings.pythonPath or IInterpreterPathService.get (which I think is used to set pythonPath).

One challenge is how to determine whether the result of interpreterSelector.getRecommendedSuggestion should be ignored in favor of defaultInterpreterPath. They should be doing something similar upstream so there should be a solution.

@seeM seeM added area: runtimes Issues related to Language Runtimes enhancement New feature or request lang: python labels Feb 11, 2025
@sharon-wang
Copy link
Member

Adding this to #6202, as we intend to document python.defaultInterpreterPath for Workbench admins as the method to set a default interpreter for users.

@juliasilge juliasilge added this to the 2025.03 Pre-Release milestone Feb 12, 2025
@isabelizimm isabelizimm self-assigned this Feb 18, 2025
isabelizimm added a commit that referenced this issue Mar 11, 2025
Adds in a selection process for implicitly or immediately starting a
runtime before discovery in `recommendWorkspaceRuntime()`. The hope here
is that, if there is a local env or a user-defined environment we know
about _before_ discovery, we can automatically select it.

### Release Notes

<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
  The note will automatically be tagged with the language.

These notes are typically filled by the Positron team. If you are an
external
  contributor, you may ignore this section.
-->


#### New Features

- #6281 
- #6204 

#### Bug Fixes

- N/A


### QA Notes

<!--
  Add additional information for QA on how to validate the change,
  paying special attention to the level of risk, adjacent areas that
  could be affected by the change, and any important contextual
  information not present in the linked issues.
-->

I have a few scenarios highlighted and what is expected. Since this part
of the codebase cares a lot about past selections, I'd highly recommend
clearing state and then restoring settings by running:

```
rm -rf ~/.vscode-oss-dev/;
rm -rf ~/.positron-dev;
mkdir -p ~/.vscode-oss-dev/User; 
touch ~/.vscode-oss-dev/User/settings.json; 
echo '{"python.defaultInterpreterPath": "PATH TO SOME PYTHON"}' > ~/.vscode-oss-dev/User/settings.json
```

| scenario | expected |
|
-------------------------------------------------------------------------------------------------------------------------------------
| ---------------------------------------------------------- |
| in workspace:<br>has .venv<br>has user level defaultInterpreterPath
set | .venv<br>immediate startup |
| in workspace:<br>had active runtime when Positron shut down<br>has
user level defaultInterpreterPath | previous active runtime<br>immediate
startup<br> |
| in workspace:<br>brand new, no affiliated runtime<br>has user level
defaultInterpreterPath set | user level
defaultInterpreterPath<br>implicit startup |
| in workspace:<br>no affiliated runtime<br>has workspace level
defaultInterpreterPath set<br>has user level defaultInterpreterPath set
| workspace level defaultInterpreterPath<br>implicit startup |
| no workspace:<br>has user level defaultInterpreterPath set | user
level defaultInterpreterPath<br>implicit startup |

---------

Signed-off-by: Isabel Zimmerman <[email protected]>
Co-authored-by: Wasim Lorgat <[email protected]>
Co-authored-by: sharon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtimes Issues related to Language Runtimes enhancement New feature or request lang: python
Projects
None yet
Development

No branches or pull requests

4 participants