Skip to content

Conversation

kimadeline
Copy link

@kimadeline kimadeline commented Jul 20, 2021

Closes #16727

Note: The check that we wanted to use to prevent auto-selection from running again (checking the workspace state using getWorkspaceState doesn't work.

const autoSelectedPythonInterpreter = this.interpreterAutoSelectionService.getAutoSelectedInterpreter(
this.workspaceRoot,
);
if (autoSelectedPythonInterpreter) {
this.pythonPath = autoSelectedPythonInterpreter.path;
if (this.workspaceRoot) {
this.interpreterAutoSelectionService
.setWorkspaceInterpreter(this.workspaceRoot, autoSelectedPythonInterpreter)
.ignoreErrors();
}
}

PythonSettings.update makes the earliest auto-selection related call, and it turns out that the return value on line 679 will be the global interpreter:

public getAutoSelectedInterpreter(resource: Resource): PythonEnvironment | undefined {
// Do not execute anycode other than fetching fromm a property.
// This method gets invoked from settings class, and this class in turn uses classes that relies on settings.
// I.e. we can end up in a recursive loop.
const workspaceState = this.getWorkspaceState(resource);
if (workspaceState && workspaceState.value) {
return workspaceState.value;
}
const workspaceFolderPath = this.getWorkspacePathKey(resource);
if (this.autoSelectedInterpreterByWorkspace.has(workspaceFolderPath)) {
return this.autoSelectedInterpreterByWorkspace.get(workspaceFolderPath);
}
return this.globallyPreferredInterpreter.value;
}

So autoSelectedPythonInterpreter will always be set. We can revisit that once we release though (#16735).

@kimadeline kimadeline added no-changelog No news entry required skip tests Updates to tests unnecessary labels Jul 20, 2021
@kimadeline kimadeline self-assigned this Jul 20, 2021
@kimadeline kimadeline removed the skip tests Updates to tests unnecessary label Jul 20, 2021
@kimadeline kimadeline merged commit 0d910c6 into microsoft:release-2021.07 Jul 20, 2021
@kimadeline kimadeline deleted the 16727-autoselection-cache branch July 20, 2021 20:32
karthiknadig added a commit that referenced this pull request Jul 22, 2021
* Fix 'Cannot read property 'resolveEnv' of undefined' error (#16677)

* Cherry pick fixes into release (#16686)

* Bump actions/setup-node from 2.1.5 to 2.2.0 (#16592)

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.1.5 to 2.2.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@v2.1.5...v2.2.0)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add support for starting TensorBoard session with a remote log directory via URL (#16477)

* Add support for remote logdirs

* Add missing keys

* Fix typo

* Bump isort from 5.8.0 to 5.9.2 (#16636)

Bumps [isort](https://github.com/pycqa/isort) from 5.8.0 to 5.9.2.
- [Release notes](https://github.com/pycqa/isort/releases)
- [Changelog](https://github.com/PyCQA/isort/blob/main/CHANGELOG.md)
- [Commits](PyCQA/isort@5.8.0...5.9.2)

---
updated-dependencies:
- dependency-name: isort
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Make getInterpreters() API faster for subsequent calls (#16674)

* Change the way auto-selection works (#16644)

* New comparison logic

* Add experiment group

* Register and call it

* Add service registry tests

* Add interpreter selector unit tests

* Add comparison unit tests

* Add intepreter selector test

* News file

* Adjust comments

* Reuse getSortName

* Add new auto-selection logic

* Add tests for getEnvTypeHeuristic

* Move persistent store initialization back out

* Update tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>
Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

* Change version for release (#16722)

* Ensure we block on autoselection when no interpreter is explictly set by user (#16723)

* Ensure we block on autoselection when no interpreter is explictly set by user

* Added tests

* News entry

* Update change log for release. (#16731)

* Fix autoselection when opening a python file directly (#16733)

* Fix autoselection when opening a python file directly

* Update changelog

* Add tests

* Ignore cache when querying for interpreters during auto-selection (#16734)

* Ignore cache when getting envs for autoselection

* Don't call autoSelectInterpreter twice

* Update debugger via point release (#16746)

* Update version

* Update change log

* Update wheels to 3.9 (#16745)

* Clean up

Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
karthiknadig added a commit that referenced this pull request Jul 28, 2021
* Fix 'Cannot read property 'resolveEnv' of undefined' error (#16677)

* Cherry pick fixes into release (#16686)

* Bump actions/setup-node from 2.1.5 to 2.2.0 (#16592)

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.1.5 to 2.2.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@v2.1.5...v2.2.0)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add support for starting TensorBoard session with a remote log directory via URL (#16477)

* Add support for remote logdirs

* Add missing keys

* Fix typo

* Bump isort from 5.8.0 to 5.9.2 (#16636)

Bumps [isort](https://github.com/pycqa/isort) from 5.8.0 to 5.9.2.
- [Release notes](https://github.com/pycqa/isort/releases)
- [Changelog](https://github.com/PyCQA/isort/blob/main/CHANGELOG.md)
- [Commits](PyCQA/isort@5.8.0...5.9.2)

---
updated-dependencies:
- dependency-name: isort
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Make getInterpreters() API faster for subsequent calls (#16674)

* Change the way auto-selection works (#16644)

* New comparison logic

* Add experiment group

* Register and call it

* Add service registry tests

* Add interpreter selector unit tests

* Add comparison unit tests

* Add intepreter selector test

* News file

* Adjust comments

* Reuse getSortName

* Add new auto-selection logic

* Add tests for getEnvTypeHeuristic

* Move persistent store initialization back out

* Update tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>
Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

* Change version for release (#16722)

* Ensure we block on autoselection when no interpreter is explictly set by user (#16723)

* Ensure we block on autoselection when no interpreter is explictly set by user

* Added tests

* News entry

* Update change log for release. (#16731)

* Fix autoselection when opening a python file directly (#16733)

* Fix autoselection when opening a python file directly

* Update changelog

* Add tests

* Ignore cache when querying for interpreters during auto-selection (#16734)

* Ignore cache when getting envs for autoselection

* Don't call autoSelectInterpreter twice

* Update debugger via point release (#16746)

* Update version

* Update change log

* Update wheels to 3.9 (#16745)

* Point release with debugpy fix (#16776)

Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants