-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Environment Id is not static (it changes) when installing Python into an empty Conda environment #20176
Comments
This is crucial for Jupyter extension as we create Kernels (somethign you see the Kernel quick pick) & we have an Id associated with each controller.
@rebornix /cc |
Currently installing Python into the environment is considered the same as deleting the environment and creating an entirely new one, so the ID doesn't change per se as it's a new environment. The selection can still be maintained however, |
Let me know if testing above works, otherwise I'll see if we can simply do this. Due to historical reasons this wasn't possible earlier. |
Can't you instead set the Id as the Uri of the python executable? |
Discussed offline, marking this as something that can be covered in debt week. |
We discussed offline that Jupyter was passing id to resolveEnvironment, which I think was the reason why Jupyter is not able to maintain the selection here: #20176 (comment). microsoft/vscode-jupyter#11949 should fix it but this issue is still a nice to have if the ID doesn't change. |
@karrtikr can we change this to a feature request or bug, I do not think this is a debt item, If Python extension were to use the same API internally, the Python extension too would run into this exact same issue. However I can see that the Python extension is genearting its own id and using the Python executable path as the Id and the executable doesn't exist. But assumed to exist. I.e. its kind of a work around. The Jupyter extension too could work around this by generating a custom ID instead of the ID that Python provides, but that would be a work around for a bug in Python extension, hence the request for this to be treated as a bug and not a debt item.
The selection is tied directly to an environment and if that ID changes, it is not the same.
From an API perspective this is not the same, its impossible to treat them as the same if the Ids are different. Else I fail to understand the whole point of having an ID (saying its the same yet having different IDs makes no senes) |
Changing labels, I only marked it as debt so I can remember to cover it in some debt week.
Btw where is that? We use the same id in the external surface and internally AFAIK. |
I understand it's not ideal, I'm just wondering why is it critical for Jupyter when Python extension seems to work fine with it. |
I've mentioned this here #20176 (comment) Python extension is not using the Id to uniquely identifiey Python environments. If the Python extension too used the same API internally Python extension too would run into this exact same issue. I suggest chaning the code to use the Python env ID instead of the executable, that should make the issue more obvious in the Python extension. At this point the selected interpreter would change for Python extension as well. As mentioned earlier Python internally does not use the same ID, its using a work around and generating its own Id , and Jupyter too would add such a work around. |
Where is that? We use |
Ahh my mistake, yes you are using the env path. |
It is the same as ID, except for the case. I don't think Jupyter is using the API as I'm envisioning it, what're you passing to |
I've created an env {"internal":{"path":"/Users/donjayamanne/miniconda3/envs/tes05","id":"/Users/donjayamanne/miniconda3/envs/tes05","executable":{"bitness":"Unknown","sysPrefix":""},"environment":{"type":"Conda","name":"tes05","folderUri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes05","scheme":"file"}},"tools":["Conda"]},"id":"/Users/donjayamanne/miniconda3/envs/tes05"} After installing Python then the output from Python API is different {"internal":{"path":"/Users/donjayamanne/miniconda3/envs/tes05/bin/python","id":"/Users/donjayamanne/miniconda3/envs/tes05/bin/python","executable":{"uri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes05/bin/python","scheme":"file"},"bitness":"64-bit","sysPrefix":"/Users/donjayamanne/miniconda3/envs/tes05"},"environment":{"type":"Conda","name":"tes05","folderUri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes05","scheme":"file"}},"version":{"major":3,"minor":10,"micro":8,"release":{"level":"final","serial":0},"sysVersion":"3.10.8 (main, Nov 24 2022, 08:08:27) [Clang 14.0.6 ]"},"tools":["Conda"]},"id":"/Users/donjayamanne/miniconda3/envs/tes05/bin/python"}
As you can see the IDs are different. |
Here are more logs {"internal":{"path":"/Users/donjayamanne/miniconda3/envs/tes06","id":"/Users/donjayamanne/miniconda3/envs/tes06","executable":{"bitness":"Unknown"},"environment":{"type":"Conda","name":"tes06","folderUri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes06","scheme":"file"}},"tools":["Conda"]},"id":"/Users/donjayamanne/miniconda3/envs/tes06"} Before (env returned in known property) {"internal":{"path":"/Users/donjayamanne/miniconda3/envs/tes06","id":"/Users/donjayamanne/miniconda3/envs/tes06","executable":{"bitness":"Unknown"},"environment":{"type":"Conda","name":"tes06","folderUri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes06","scheme":"file"}},"tools":["Conda"]},"id":"/Users/donjayamanne/miniconda3/envs/tes06"} After (fully resolved env) {"internal":{"path":"/Users/donjayamanne/miniconda3/envs/tes06/bin/python","id":"/Users/donjayamanne/miniconda3/envs/tes06/bin/python","executable":{"uri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes06/bin/python","scheme":"file"},"bitness":"64-bit","sysPrefix":"/Users/donjayamanne/miniconda3/envs/tes06"},"environment":{"type":"Conda","name":"tes06","folderUri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes06","scheme":"file"}},"version":{"major":3,"minor":10,"micro":8,"release":{"level":"final","serial":0},"sysVersion":"3.10.8 (main, Nov 24 2022, 08:08:27) [Clang 14.0.6 ]"},"tools":["Conda"]},"id":"/Users/donjayamanne/miniconda3/envs/tes06/bin/python"} After (env returned in known property) {"internal":{"path":"/Users/donjayamanne/miniconda3/envs/tes06/bin/python","id":"/Users/donjayamanne/miniconda3/envs/tes06/bin/python","executable":{"uri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes06/bin/python","scheme":"file"},"bitness":"64-bit","sysPrefix":"/Users/donjayamanne/miniconda3/envs/tes06"},"environment":{"type":"Conda","name":"tes06","folderUri":{"$mid":1,"path":"/Users/donjayamanne/miniconda3/envs/tes06","scheme":"file"}},"version":{"major":3,"minor":10,"micro":8,"release":{"level":"final","serial":0},"sysVersion":"3.10.8 (main, Nov 24 2022, 08:08:27) [Clang 14.0.6 ]"},"tools":["Conda"]},"id":"/Users/donjayamanne/miniconda3/envs/tes06/bin/python"}
I'm confused here, I thought after our discussion you already acknowledged this was expected. |
… python is installed (#20609) Fixes #20176 As we're changing IDs we've to ensure the same environment in cache with older ID is migrated to use the new one, this is already ensured here: https://github.com/microsoft/vscode-python/blob/32f55109c976e66bf39e8da6aae0c9b6f5115df2/src/client/pythonEnvironments/base/locators/composite/envsCollectionCache.ts#L109
@DonJayamanne Can you verify this for Jupyter? |
Merging upstream vscode-python from 2023-02-03 commit fe4c5f1e4ae069160514495a717ff46f4cd11a61 -------------------- Commit message for microsoft/vscode-python@fe4c5f1: Add a button in prompt to check logs in case the selected interpreter is invalid (microsoft/vscode-python#20642) -------------------- Commit message for microsoft/vscode-python@1538833: Allow to select a Python2.7 interpreter (microsoft/vscode-python#20639) -------------------- Commit message for microsoft/vscode-python@9271136: Move `replaceAll` and `splitLines` out of string extensions. (microsoft/vscode-python#20626) For microsoft/vscode-python#18871 -------------------- Commit message for microsoft/vscode-python@e743037: Ensure editable install only when [build-system] is present `pyproject.toml` (microsoft/vscode-python#20625) Fixes microsoft/vscode-python#20620 -------------------- Commit message for microsoft/vscode-python@b43bc25: Do not recommend Python2 as an interpreter (microsoft/vscode-python#20628) -------------------- Commit message for microsoft/vscode-python@ddc765e: Fix wording in conda inherit env prompt (microsoft/vscode-python#20627) Closes microsoft/vscode-python#19001 -------------------- Commit message for microsoft/vscode-python@401418a: Ensure IDs of Conda environments without python does not change after python is installed (microsoft/vscode-python#20609) Fixes microsoft/vscode-python#20176 As we're changing IDs we've to ensure the same environment in cache with older ID is migrated to use the new one, this is already ensured here: https://github.com/microsoft/vscode-python/blob/32f55109c976e66bf39e8da6aae0c9b6f5115df2/src/client/pythonEnvironments/base/locators/composite/envsCollectionCache.ts#L109 -------------------- Commit message for microsoft/vscode-python@92d2d85: Fix test failures due to linting (microsoft/vscode-python#20617) Fixes microsoft/vscode-python#20612 -------------------- Commit message for microsoft/vscode-python@d245a90: Update to latest `jedi-language-server` (microsoft/vscode-python#20611) Fixes microsoft/vscode-python#20606 -------------------- Commit message for microsoft/vscode-python@3fe7057: new inactive discovery logic (microsoft/vscode-python#20566) New pytest code in a currently inactive state. -------------------- Commit message for microsoft/vscode-python@bf4091e: Skip windows store interpreters found via windows registry when discovering (microsoft/vscode-python#20613) Closes microsoft/vscode-python#20603 -------------------- Commit message for microsoft/vscode-python@ec2af99: Use `markdownDescription` for settings with markdown in description (microsoft/vscode-python#20600) Fixes microsoft/vscode-python#20582 -------------------- Commit message for microsoft/vscode-python@7ca872e: Add option to skip showing recommended interpreter in quick pick API (microsoft/vscode-python#20604) Closes microsoft/vscode-python#20260 -------------------- Commit message for microsoft/vscode-python@184617e: Check to ensure major version matches current year. (microsoft/vscode-python#20601) Fixes microsoft/vscode-python#20466 -------------------- Commit message for microsoft/vscode-python@328e511: Ensure dependency quick pick is not shown when user exits env creation. (microsoft/vscode-python#20605) Fixes microsoft/vscode-python#20602 -------------------- Commit message for microsoft/vscode-python@7fb72b7: Update main to next pre-release (microsoft/vscode-python#20598) -------------------- Commit message for microsoft/vscode-python@2dd9287: Set release candidate version. (microsoft/vscode-python#20597) -------------------- Commit message for microsoft/vscode-python@b83aacb: Update `debugpy` to v1.6.6 (microsoft/vscode-python#20596) -------------------- Commit message for microsoft/vscode-python@93b0053: Skip requirement files from `site-packages` or `__pypackages__` (microsoft/vscode-python#20573) Fixes microsoft/vscode-python#20560 Lead-authored-by: Karthik Nadig <[email protected]> Co-authored-by: Eleanor Boyd <[email protected]> Co-authored-by: Pete Farland <[email protected]> Co-authored-by: Kartik Raj <[email protected]>
Merging upstream vscode-python from 2023-02-03 commit fe4c5f1e4ae069160514495a717ff46f4cd11a61 -------------------- Commit message for microsoft/vscode-python@fe4c5f1: Add a button in prompt to check logs in case the selected interpreter is invalid (microsoft/vscode-python#20642) -------------------- Commit message for microsoft/vscode-python@1538833: Allow to select a Python2.7 interpreter (microsoft/vscode-python#20639) -------------------- Commit message for microsoft/vscode-python@9271136: Move `replaceAll` and `splitLines` out of string extensions. (microsoft/vscode-python#20626) For microsoft/vscode-python#18871 -------------------- Commit message for microsoft/vscode-python@e743037: Ensure editable install only when [build-system] is present `pyproject.toml` (microsoft/vscode-python#20625) Fixes microsoft/vscode-python#20620 -------------------- Commit message for microsoft/vscode-python@b43bc25: Do not recommend Python2 as an interpreter (microsoft/vscode-python#20628) -------------------- Commit message for microsoft/vscode-python@ddc765e: Fix wording in conda inherit env prompt (microsoft/vscode-python#20627) Closes microsoft/vscode-python#19001 -------------------- Commit message for microsoft/vscode-python@401418a: Ensure IDs of Conda environments without python does not change after python is installed (microsoft/vscode-python#20609) Fixes microsoft/vscode-python#20176 As we're changing IDs we've to ensure the same environment in cache with older ID is migrated to use the new one, this is already ensured here: https://github.com/microsoft/vscode-python/blob/32f55109c976e66bf39e8da6aae0c9b6f5115df2/src/client/pythonEnvironments/base/locators/composite/envsCollectionCache.ts#L109 -------------------- Commit message for microsoft/vscode-python@92d2d85: Fix test failures due to linting (microsoft/vscode-python#20617) Fixes microsoft/vscode-python#20612 -------------------- Commit message for microsoft/vscode-python@d245a90: Update to latest `jedi-language-server` (microsoft/vscode-python#20611) Fixes microsoft/vscode-python#20606 -------------------- Commit message for microsoft/vscode-python@3fe7057: new inactive discovery logic (microsoft/vscode-python#20566) New pytest code in a currently inactive state. -------------------- Commit message for microsoft/vscode-python@bf4091e: Skip windows store interpreters found via windows registry when discovering (microsoft/vscode-python#20613) Closes microsoft/vscode-python#20603 -------------------- Commit message for microsoft/vscode-python@ec2af99: Use `markdownDescription` for settings with markdown in description (microsoft/vscode-python#20600) Fixes microsoft/vscode-python#20582 -------------------- Commit message for microsoft/vscode-python@7ca872e: Add option to skip showing recommended interpreter in quick pick API (microsoft/vscode-python#20604) Closes microsoft/vscode-python#20260 -------------------- Commit message for microsoft/vscode-python@184617e: Check to ensure major version matches current year. (microsoft/vscode-python#20601) Fixes microsoft/vscode-python#20466 -------------------- Commit message for microsoft/vscode-python@328e511: Ensure dependency quick pick is not shown when user exits env creation. (microsoft/vscode-python#20605) Fixes microsoft/vscode-python#20602 -------------------- Commit message for microsoft/vscode-python@7fb72b7: Update main to next pre-release (microsoft/vscode-python#20598) -------------------- Commit message for microsoft/vscode-python@2dd9287: Set release candidate version. (microsoft/vscode-python#20597) -------------------- Commit message for microsoft/vscode-python@b83aacb: Update `debugpy` to v1.6.6 (microsoft/vscode-python#20596) -------------------- Commit message for microsoft/vscode-python@93b0053: Skip requirement files from `site-packages` or `__pypackages__` (microsoft/vscode-python#20573) Fixes microsoft/vscode-python#20560 Lead-authored-by: Karthik Nadig <[email protected]> Co-authored-by: Eleanor Boyd <[email protected]> Co-authored-by: Pete Farland <[email protected]> Co-authored-by: Kartik Raj <[email protected]>
@karrtikr I'd expect the Id to be the same everytime and not change.
Can we have the env id to be always sysprefix or the like, somethign that will never change for the same environment.
The text was updated successfully, but these errors were encountered: