-
Notifications
You must be signed in to change notification settings - Fork 673
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
Fix asynchronous environment discovery and selection #7489
Conversation
Case 1 - Conda environment foundTo repro:
Scenario 1 - Single conda environment (selected), no other environmentsExpected behavior - On project load, no environments are found. So the global default is added and activated. Then, when the conda environment is detected, it's added to the solution explorer and the global default is removed. Since the conda environment is the one specified as active in the pyproj, it gets activated. Actual behavior - The conda environment is never added to the solution explorer. The InterpreterId specified in the pyproj isn't found. ✅ Open existing solution is now working correctly Scenario 2 - Single conda environment (selected), single virtual environmentExpected behavior - On project load, a single environment is found (the virtual environment). This environment should NOT be activated since it's not the one specified as active in the pyproj. When the conda environment is detected, it's added to the solution explorer. Since the conda environment is the one specified as active in the pyproj, it gets activated. Actual behavior - On project load, a single environment is found (the virtual environment). Since there are no other environments, this virtual env is activated, even though it's NOT the one specified as active in the pyproj. This is a problem since the The fix is not to activate environments arbitrarily, which is what the code was doing. ✅ This is now working correctly. We no longer arbitrarily select an interpreter as active. The "missing" conda interpreter shows up at missing with NOTHING selected at first. Then, once the conda environment is detected, the list is updated and the conda environment is selected and bolded. Scenario 3 - Single conda environment, single virtual environment (selected)Expected behavior - Both environments load correctly, virtualEnv is selected and bolded Actual behavior - Both environments do load correctly, virtualEnv is selected and bolded. BUT we get an info bar saying there's a reference to a missing conda environment. The fix is either to delay the info bar displaying for conda environments, or remove it, or hide the info bar once the conda environment is finished being detected. ✅ This is now working correctly. The normal infobar checks still run, but the conda infobar check is delayed until conda environment discovery is finished. |
Case 2 - Conda environment not found (project view)To repro:
Scenario 1 - Only conda environment in listExpected behavior - Conda environment shows as missing in the python environments folder, global environment loads correctly and is activated, info bar is displayed that says conda env is missing. ✅ Works as intended Scenario 2 - Virtual environment also in listExpected behavior - Conda environment shows as missing in the python environments folder, virtual environment loads correctly and is activated, info bar is displayed that says conda env is missing. ✅ Works as intended |
Python/Product/VSInterpreters/Interpreter/InterpreterRegistryService.cs
Outdated
Show resolved
Hide resolved
Python/Product/PythonTools/PythonTools/Project/PythonProjectNode.cs
Outdated
Show resolved
Hide resolved
Python/Product/PythonTools/PythonTools/Project/PythonProjectNode.cs
Outdated
Show resolved
Hide resolved
Python/Product/VSInterpreters/Interpreter/InterpreterRegistryService.cs
Outdated
Show resolved
Hide resolved
Thank you very much for adding copious comments; this will help a lot in the future! |
Kudos, SonarCloud Quality Gate passed! |
Fixes #7444
There are some bugs around environment loading and selection when the environments are discovered asynchronously, like with conda environments. There are lots of edge cases that need to be tested. See comments below for each scenario.
Specifically, conda environments weren't being shown in solution explorer because the currently selected environment was the global default, and the existing conditional was not behaving properly in that case. We were also showing an infobar for "missing conda environment" before they had a chance to be discovered.