Skip to content

Conversation

@karrtikr
Copy link

@karrtikr karrtikr commented Feb 10, 2021

We were activating the discovery component before we even register all the classes that the component might need, which led in a few issues as mentioned in #15132 (comment). Removed this activation. Note we already activate using the component adapter for the discovery component so not calling activate() is not a problem.

Opened #15380 to fix this in a general way for all components.

Reverts some parts of #15132

@karrtikr karrtikr added no-changelog No news entry required skip tests Updates to tests unnecessary labels Feb 10, 2021
@karrtikr karrtikr changed the title Revert "Only force background envs refresh if the component is enabled." Do not call activate the discovery component before registering all the classes Feb 10, 2021
@karrtikr karrtikr force-pushed the revert-15132-pyenvs-component-activate-if-in-experiment branch from 24dd818 to 58a5e11 Compare February 10, 2021 21:33
@karrtikr karrtikr marked this pull request as ready for review February 10, 2021 21:45
@karthiknadig
Copy link
Member

This cannot be merged by itself. It will turn off the discovery component.

@karrtikr
Copy link
Author

karrtikr commented Feb 10, 2021

Note we already activate using the component adapter for the discovery component so not calling activate() is not a problem.

@karthiknadig I have mentioned this in the description. It won't turn off the component as we already activate using the component adapter.

Right here:

// Get latest interpreter list in the background.
this.interpreterService.getInterpreters(resource).ignoreErrors();

@karrtikr
Copy link
Author

I have cleared this up in the comment as well.

@karthiknadig
Copy link
Member

Ah! yes. I missed that part. Thanks for taking care of this.

Copy link

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it not work to just move activateLegacy() first?

@karrtikr
Copy link
Author

karrtikr commented Feb 10, 2021

@ericsnowcurrently We can do that too, but we need not block activating components on all of activateLegacy(), we only need to block it on registration. So the right solution will be to separate registration from activateLegacy() which #15380 is intended for.

@ericsnowcurrently
Copy link

The right solution is to pass the relevant objects into the component init/activation, block in components where necessary, and eventually eliminate activateLegacy().

@karrtikr
Copy link
Author

Yes eventually when we have everything refactored into components, #15380 can be thought of as an intermediately step. But either way, any solution we go with right now is a temporary solution, so I think this is okay.

@ericsnowcurrently
Copy link

With your change we are disabling activation of the component. If you move the activateLegacy() call then you shouldn't need to disable anything.

@karrtikr
Copy link
Author

karrtikr commented Feb 11, 2021

@ericsnowcurrently Please read #15379 (comment). The component adapter already activates it.

@ericsnowcurrently
Copy link

@ericsnowcurrently Please read #15379 (comment). The component adapter already activates it.

That isn't happening in the component adapter. It's code related to the old discovery machinery. I'd argue that the line in activationManager.ts should only be run if not in the experiment.

Regardless, that line is only pre-running env discovery. That part of the extension has no knowledge of what the envs component needs to do during activation. It only happens to be doing what the component does during activation. Instead, the component should be strictly in charge of its activation. We shouldn't short-circuit that design for the sake of any short-term objectives, else we'll end up back with the tangle of special cases and interdependence we're trying to eliminate with the component work.

@ericsnowcurrently
Copy link

We were activating the discovery component before we even register all the classes that the component might need,

Which classes does it rely on? (It seems that we've ended up with the component depending on the old DI framework, which is exactly what we were working to avoid in the component.)

@karrtikr
Copy link
Author

Which classes does it rely on? (It seems that we've ended up with the component depending on the old DI framework, which is exactly what we were working to avoid in the component.)

It relies on IInterpreterService (which is actually not part of the old DI framework), it then calls the adapter based on if we're in discovery experiment, which is fine.

And you're right, I was looking at it short-term. I can and will change the code to call activateLegacy() first, but it still has its problems #15379 (comment) so it is short term too.

@karrtikr karrtikr force-pushed the revert-15132-pyenvs-component-activate-if-in-experiment branch from fa345df to 9e1e04f Compare February 11, 2021 18:56
Copy link

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for the changes. Ideally we would not have introduced the dependencies on the legacy code in the first place. However, at this point it's something to correct later. 😞

@karrtikr
Copy link
Author

karrtikr commented Feb 11, 2021

@ericsnowcurrently InterpreterService is not all legacy code tho, it queries legacy code based on if we're in experiment. Please have a look.

@karrtikr karrtikr merged commit 334a3bb into main Feb 11, 2021
@karrtikr karrtikr deleted the revert-15132-pyenvs-component-activate-if-in-experiment branch February 11, 2021 22:03
@karrtikr karrtikr restored the revert-15132-pyenvs-component-activate-if-in-experiment branch February 11, 2021 22:03
@karrtikr karrtikr deleted the revert-15132-pyenvs-component-activate-if-in-experiment branch February 11, 2021 22:04
@ericsnowcurrently
Copy link

Sorry, I should have been more clear. If it isn't in src/client/pythonEnvironments then I consider it legacy code. (Plus, InterpreterService was added in 2018 and will be gone once we move everything else to components.)

Regardless, thanks for fixing this.

karthiknadig pushed a commit to karthiknadig/vscode-python that referenced this pull request Feb 17, 2021
…he classes (microsoft#15379)

* Do not attempt to activate discovery component before registering all the classes

* Add clarification comment

* Code reviews
karthiknadig added a commit that referenced this pull request Feb 17, 2021
* Do not call activate the discovery component before registering all the classes (#15379)

* Do not attempt to activate discovery component before registering all the classes

* Add clarification comment

* Code reviews

* Skip windows store and shims paths when using known path locators (#15388)

* Skip windows store and shims paths when using known path locators

* Clean up and comments

* Tests

* Handle cases where envs variables might not be set

* Typo

Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

* Change "Pylance not installed" prompt to allow reverting to Jedi (#15420)

* Allow on suggestion refresh by default (#15430)

Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
karthiknadig added a commit that referenced this pull request Feb 18, 2021
* Cherry pick fix for native notebook support into release branch (#15369)

* Fix problem with notebook apis not being used. (#15366)

* Update changelog

* Remove news file

* Add extraPaths support to JediLSP (#15365)

* Add extraPaths support

* Remove duplicate opt option

* Eslint cleanup

* Fix tests

* Ignore directories with the same name as python binaries (#15367)

* Ignore directories with the same name as pyhton binaries

* Use withFileTypes instead of lstat

* Correct pipenv activation provider when in discovery experiment (#15319)

* Correct pipenv activation provider when in discovery experiment

* Fix ESLint errors

* In PythonEnvsReducer.resolveEnv(), always fall back to the wrapped locator. (#15350)

fixes #15118

* Fix issue with missing interpreter info for some cases  (#15376)

* Use child process apis directly.

* Use raw API in process service

* Handle process cleanup

* Address sonar

* Refactor process service by pulling the raw process APIs out of the class

* Address comments

* Add reference to CVE-2020-16977 fixed in Oct 2020. (#15381)

* Fix CI failing with the number of constructor arguments error (#15347)

* Fix Command 'workbench.action.closeAllEditors' timed out failure on CI (#15322)

* Ensure environment variables provider can be created using standard classes (#15377)

* Ensure environment variables provider can be created using standard classes

* Fix unit tests

* Fix ESLint errors for environment variable provider (#15383)

* Fix problem with notebook apis not being used. (#15366)

* Show Python: Launch TensorBoard command in command palette (#15382) (#15386)

* Always register Launch TensorBoard command

* Put usage tracking behind experiment

* Cherry picks from main to release (#15421)

* Do not call activate the discovery component before registering all the classes (#15379)

* Do not attempt to activate discovery component before registering all the classes

* Add clarification comment

* Code reviews

* Skip windows store and shims paths when using known path locators (#15388)

* Skip windows store and shims paths when using known path locators

* Clean up and comments

* Tests

* Handle cases where envs variables might not be set

* Typo

Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

* Change "Pylance not installed" prompt to allow reverting to Jedi (#15420)

* Allow on suggestion refresh by default (#15430)

Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>

Co-authored-by: Rich Chiodo <rchiodo@users.noreply.github.com>
Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: Eric Snow <eric.snow@microsoft.com>
Co-authored-by: Jim Griesmer <jimgries@microsoft.com>
Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
karthiknadig added a commit that referenced this pull request Mar 8, 2021
* Cherry pick fix for native notebook support into release branch (#15369)

* Fix problem with notebook apis not being used. (#15366)

* Update changelog

* Remove news file

* Add extraPaths support to JediLSP (#15365)

* Add extraPaths support

* Remove duplicate opt option

* Eslint cleanup

* Fix tests

* Ignore directories with the same name as python binaries (#15367)

* Ignore directories with the same name as pyhton binaries

* Use withFileTypes instead of lstat

* Correct pipenv activation provider when in discovery experiment (#15319)

* Correct pipenv activation provider when in discovery experiment

* Fix ESLint errors

* In PythonEnvsReducer.resolveEnv(), always fall back to the wrapped locator. (#15350)

fixes #15118

* Fix issue with missing interpreter info for some cases  (#15376)

* Use child process apis directly.

* Use raw API in process service

* Handle process cleanup

* Address sonar

* Refactor process service by pulling the raw process APIs out of the class

* Address comments

* Add reference to CVE-2020-16977 fixed in Oct 2020. (#15381)

* Fix CI failing with the number of constructor arguments error (#15347)

* Fix Command 'workbench.action.closeAllEditors' timed out failure on CI (#15322)

* Ensure environment variables provider can be created using standard classes (#15377)

* Ensure environment variables provider can be created using standard classes

* Fix unit tests

* Fix ESLint errors for environment variable provider (#15383)

* Fix problem with notebook apis not being used. (#15366)

* Show Python: Launch TensorBoard command in command palette (#15382) (#15386)

* Always register Launch TensorBoard command

* Put usage tracking behind experiment

* Cherry picks from main to release (#15421)

* Do not call activate the discovery component before registering all the classes (#15379)

* Do not attempt to activate discovery component before registering all the classes

* Add clarification comment

* Code reviews

* Skip windows store and shims paths when using known path locators (#15388)

* Skip windows store and shims paths when using known path locators

* Clean up and comments

* Tests

* Handle cases where envs variables might not be set

* Typo

Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

* Change "Pylance not installed" prompt to allow reverting to Jedi (#15420)

* Allow on suggestion refresh by default (#15430)

Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>

* Release final (#15433)

* Version update

* Change log updates

* TPN update

* Ensure pyenv virtual envs are not skipped when in discovery experiment (#15451)

* Ensure pyenv virtual envs are not skipped

* Add news

* Clean up

* Address comments

* Register Jedi regardless of what language server is configured (#15452)

* Register Jedi regardless of what language server is configured

* News entry

* Only call component adapter behind the discovery experiment (#15459)

* Update version and change log for point release (#15463)

* Version update

* Update change log

* Update start-up telemetry for Jedi LSP (#15419) (#15571)

* Version and change log update for point release (#15572)

Co-authored-by: Rich Chiodo <rchiodo@users.noreply.github.com>
Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: Eric Snow <eric.snow@microsoft.com>
Co-authored-by: Jim Griesmer <jimgries@microsoft.com>
Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
Co-authored-by: Jake Bailey <5341706+jakebailey@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 skip tests Updates to tests unnecessary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants