Repository navigation
Python Extension API incorrectly triggers 'remove' event #20292
Copy link
Copy link
Closed
microsoft/vscode-jupyter
#12962Labels
area-environmentsFeatures relating to handling interpreter environmentsFeatures relating to handling interpreter environmentsbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked onReady to be worked onneeds spikeLabel for issues that need investigation before they can be worked on.Label for issues that need investigation before they can be worked on.verifiedVerification succeededVerification succeeded
Milestone
Description
On CI we're using a Python global Python env,
In the middle of the tests, the Python extension API triggers and event indicating the python environment has been deleted
and this then causes a few other issues in Jupyter extension
Note: We do not delete the global python env hence I do not expect to receive such and event.
If we're using the event incorrectly please do let us know.
Here are the interesting logs
- Jupyter Logs
2022-11-30T00:05:36.8558283Z verbose 00:05:36.535: Interpreter removed /opt/hostedtoolcache/Python/3.10.8/x64/bin/python
2022-11-30T00:05:36.8560009Z verbose 00:05:36.535: Interpreter /opt/hostedtoolcache/Python/3.10.8/x64/bin/python deleted, hence deleting corresponding kernel startUsingPythonInterpreter:'.jvsc74a57bd079f32d02658bf12f8569a265222c57f47d77ad75a8d38a3c9f42a05c99ab6a7e./opt/hostedtoolcache/Python/3.10.8/x64/python./opt/hostedtoolcache/Python/3.10.8/x64/python.-m#ipykernel_launcher
2022-11-30T00:05:36.8562018Z verbose 00:05:36.535: Local Python connection deleted startUsingPythonInterpreter:'.jvsc74a57bd079f32d02658bf12f8569a265222c57f47d77ad75a8d38a3c9f42a05c99ab6a7e./opt/hostedtoolcache/Python/3.10.8/x64/python./opt/hostedtoolcache/Python/3.10.8/x64/python.-m#ipykernel_launcher: (interpreter id=/opt/hostedtoolcache/Python/3.10.8/x64/bin/python)'
2022-11-30T00:05:36.8568304Z verbose 00:05:36.536: Updating cache with Local kernels startUsingLocalKernelSpec:'..net-csharp./dotnet./.dotnet#interactive#jupyter#--default-kernel#csharp#{connection_file}#--http-port-range#2048-3000 (interpreter id = undefined)', startUsingLocalKernelSpec:'..net-fsharp./dotnet./.dotnet#interactive#jupyter#--default-kernel#fsharp#{connection_file}#--http-port-range#2048-3000 (interpreter id = undefined)', startUsingLocalKernelSpec:'..net-powershell./dotnet./.dotnet#interactive#jupyter#--default-kernel#powershell#{connection_file}#--http-port-range#2048-3000 (interpreter id = undefined)', startUsingLocalKernelSpec:'.julia-1.5./opt/hostedtoolcache/julia/1.5.2/x64/bin/julia././opt/hostedtoolcache/julia/1.5.2/x64/bin/julia#-i#--color=yes#--project=@.#/home/runner/.julia/packages/ijulia/aqu2h/src/kernel.jl#{connection_file} (interpreter id = undefined)', startUsingLocalKernelSpec:'..venvkernel./home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel/python./home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel/python.-m#ipykernel_launcher (interpreter id = /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel/bin/python)', startUsingLocalKernelSpec:'..venvnokernel./home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel/python./home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel/python.-m#ipykernel_launcher (interpreter id = /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel/bin/python)'
& here are the logs from Python extension at the same time
[INFO 2022-10-30 0:5:35.965]: Found interpreter for >> /opt/hostedtoolcache/Python/3.10.8/x64/python /tmp/vscode_jupyter_exts/ms-python.python-2022.19.13321005/pythonFiles/get_output_via_markers.py /tmp/vscode_jupyter_exts/ms-python.python-2022.19.13321005/pythonFiles/interpreterInfo.py <<: {"versionInfo":[3,10,8,"final",0],"sysPrefix":"/opt/hostedtoolcache/Python/3.10.8/x64/.","sysVersion":"3.10.8 (main, Oct 18 2022, 06:43:21) [GCC 9.4.0]","is64Bit":true}
[DEBUG 2022-10-30 0:5:35.968]: No cached env found for /opt/hostedtoolcache/Python/3.10.8/x64/bin/python
[INFO 2022-10-30 0:5:35.970]: Environments added to cache [{"name":"base","location":"/usr/share/miniconda","kind":"virt-conda","executable":{"filename":"/usr/share/miniconda/bin/python","sysPrefix":"/usr/share/miniconda","ctime":1668862752754,"mtime":1668862752754},"display":"Python 3.9.12 ('base')","version":{"major":3,"minor":9,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.9.12 (main, Apr 5 2022, 06:56:58) \n[GCC 7.5.0]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/usr/share/miniconda/bin/python","detailedDisplayName":"Python 3.9.12 ('base': conda)"},{"name":".venvkernel","location":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel","kind":"virt-venv","executable":{"filename":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel/bin/python","sysPrefix":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel","ctime":1669766644084,"mtime":1669766644084},"searchLocation":{"$mid":1,"fsPath":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel","path":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel","scheme":"file"},"display":"Python 3.10.8 ('.venvkernel': venv)","version":{"major":3,"minor":10,"micro":8,"release":{"level":"final","serial":0},"sysVersion":"3.10.8 (main, Oct 18 2022, 06:43:21) [GCC 9.4.0]"},"arch":3,"distro":{"org":""},"source":[],"type":"Virtual","id":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel/bin/python","detailedDisplayName":"Python 3.10.8 ('.venvkernel': venv)"},{"name":".venvnokernel","location":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel","kind":"virt-venv","executable":{"filename":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel/bin/python","sysPrefix":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel","ctime":1669766672094,"mtime":1669766672094},"searchLocation":{"$mid":1,"fsPath":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel","path":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel","scheme":"file"},"display":"Python 3.10.8 ('.venvnokernel': venv)","version":{"major":3,"minor":10,"micro":8,"release":{"level":"final","serial":0},"sysVersion":"3.10.8 (main, Oct 18 2022, 06:43:21) [GCC 9.4.0]"},"arch":3,"distro":{"org":""},"source":[],"type":"Virtual","id":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel/bin/python","detailedDisplayName":"Python 3.10.8 ('.venvnokernel': venv)"},{"name":".venvnoreg","location":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnoreg","kind":"virt-venv","executable":{"filename":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnoreg/bin/python","sysPrefix":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnoreg","ctime":1669766640228,"mtime":1669766640228},"searchLocation":{"$mid":1,"fsPath":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnoreg","path":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnoreg","scheme":"file"},"display":"Python 3.10.8 ('.venvnoreg': venv)","version":{"major":3,"minor":10,"micro":8,"release":{"level":"final","serial":0},"sysVersion":"3.10.8 (main, Oct 18 2022, 06:43:21) [GCC 9.4.0]"},"arch":3,"distro":{"org":""},"source":[],"type":"Virtual","id":"/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnoreg/bin/python","detailedDisplayName":"Python 3.10.8 ('.venvnoreg': venv)"},{"name":"","location":"","kind":"global-other","executable":{"filename":"/bin/python","sysPrefix":"/usr","ctime":1668861006324,"mtime":1586947544000},"display":"Python 3.8.10 64-bit","version":{"major":3,"minor":8,"micro":10,"release":{"level":"final","serial":0},"sysVersion":"3.8.10 (default, Jun 22 2022, 20:18:18) \n[GCC 9.4.0]"},"arch":3,"distro":{"org":""},"source":["path env var"],"id":"/bin/python","detailedDisplayName":"Python 3.8.10 64-bit"},{"name":"","location":"","kind":"global-other","executable":{"filename":"/bin/python2","sysPrefix":"/usr","ctime":1668860991299,"mtime":1584102683000},"display":"Python 2.7.18 64-bit","version":{"major":2,"minor":7,"micro":18,"release":{"level":"final","serial":0},"sysVersion":"2.7.18 (default, Jul 1 2022, 12:27:04) \n[GCC 9.4.0]"},"arch":3,"distro":{"org":""},"source":["path env var"],"id":"/bin/python2","detailedDisplayName":"Python 2.7.18 64-bit"},{"name":"","location":"","kind":"global-other","executable":{"filename":"/usr/bin/python","sysPrefix":"/usr","ctime":1668861006324,"mtime":1586947544000},"display":"Python 3.8.10 64-bit","version":{"major":3,"minor":8,"micro":10,"release":{"level":"final","serial":0},"sysVersion":"3.8.10 (default, Jun 22 2022, 20:18:18) \n[GCC 9.4.0]"},"arch":3,"distro":{"org":""},"source":["path env var"],"id":"/usr/bin/python","detailedDisplayName":"Python 3.8.10 64-bit"},{"name":"","location":"","kind":"global-other","executable":{"filename":"/opt/hostedtoolcache/Python/3.10.8/x64/python","sysPrefix":"/opt/hostedtoolcache/Python/3.10.8/x64/.","ctime":1669766020363,"mtime":1668865149931},"display":"Python 3.10.8 64-bit","version":{"major":3,"minor":10,"micro":8,"release":{"level":"final","serial":0},"sysVersion":"3.10.8 (main, Oct 18 2022, 06:43:21) [GCC 9.4.0]"},"arch":3,"distro":{"org":""},"source":["path env var"],"id":"/opt/hostedtoolcache/Python/3.10.8/x64/python","detailedDisplayName":"Python 3.10.8 64-bit"}]
[INFO 2022-10-30 0:5:35.971]: [
'Display locator refreshing progress, Class name = f, completed in 0ms, has a falsy return value, , Return Value: undefined'
]
[INFO 2022-10-30 0:5:35.973]: [
'Hide locator refreshing progress, Class name = f, completed in 0ms, has a falsy return value, , Return Value: undefined'
]
[DEBUG 2022-10-30 0:5:35.975]: Cached data exists KeyPrefix=Cache_Method_Output_m.addKeyToStorage-Args="workspace"-Arg-Separator-"autoSelectedWorkspacePythonInterpreter-/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience"-Arg-Separator-undefined
[DEBUG 2022-10-30 0:5:35.976]: Cached data exists KeyPrefix=Cache_Method_Output_m.addKeyToStorage-Args="global"-Arg-Separator-"WORKSPACE_FOLDER_INTERPRETER_PATH_/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience"-Arg-Separator-undefined
[DEBUG 2022-10-30 0:5:35.976]: Cached data exists KeyPrefix=Cache_Method_Output_m.addKeyToStorage-Args="global"-Arg-Separator-"WORKSPACE_FOLDER_INTERPRETER_PATH_/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience"-Arg-Separator-undefined
[DEBUG 2022-10-30 0:5:35.978]: Cached data exists KeyPrefix=Cache_Method_Output_m.addKeyToStorage-Args="global"-Arg-Separator-"WORKSPACE_FOLDER_INTERPRETER_PATH_/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience"-Arg-Separator-undefined
[DEBUG 2022-10-30 0:5:35.978]: Cached data exists KeyPrefix=Cache_Method_Output_m.addKeyToStorage-Args="global"-Arg-Separator-"WORKSPACE_FOLDER_INTERPRETER_PATH_/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience"-Arg-Separator-undefined
[DEBUG 2022-10-30 0:5:35.996]: Cached data exists KeyPrefix=Cache_Method_Output_m.addKeyToStorage-Args="global"-Arg-Separator-"WORKSPACE_FOLDER_INTERPRETER_PATH_/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience"-Arg-Separator-undefined
[DEBUG 2022-10-30 0:5:35.996]: Cached data exists KeyPrefix=Cache_Method_Output_m.addKeyToStorage-Args="global"-Arg-Separator-"WORKSPACE_FOLDER_INTERPRETER_PATH_/home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience"-Arg-Separator-undefined
[DEBUG 2022-10-30 0:5:36.7]: Searching for conda environments using conda
[DEBUG 2022-10-30 0:5:36.7]: Cached data exists KeyPrefix=Cache_Method_Output_y.getEnvList-Args=
[DEBUG 2022-10-30 0:5:36.18]: Looking into conda env for executable: {"prefix":"/usr/share/miniconda","name":"base"}
[DEBUG 2022-10-30 0:5:36.34]: Searching for workspace virtual envs in: /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience
[DEBUG 2022-10-30 0:5:36.35]: Found executable within conda env {"prefix":"/usr/share/miniconda","name":"base"}
[DEBUG 2022-10-30 0:5:36.35]: Found conda executable: /usr/share/miniconda/bin/python
[DEBUG 2022-10-30 0:5:36.59]: Workspace Virtual Environment: [added] /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel/bin/python
[DEBUG 2022-10-30 0:5:36.59]: Workspace Virtual Environment: [skipped] /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel/bin/python3
[DEBUG 2022-10-30 0:5:36.59]: Workspace Virtual Environment: [skipped] /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvkernel/bin/python3.10
[DEBUG 2022-10-30 0:5:36.59]: No cached env found for /opt/hostedtoolcache/Python/3.10.8/x64/bin/python
[DEBUG 2022-10-30 0:5:36.59]: No cached env found for /opt/hostedtoolcache/Python/3.10.8/x64/bin/python
[DEBUG 2022-10-30 0:5:36.59]: No cached env found for /opt/hostedtoolcache/Python/3.10.8/x64/bin/python
[DEBUG 2022-10-30 0:5:36.59]: No cached env found for /opt/hostedtoolcache/Python/3.10.8/x64/bin/python
[DEBUG 2022-10-30 0:5:36.59]: No cached env found for /opt/hostedtoolcache/Python/3.10.8/x64/bin/python
[INFO 2022-10-30 0:5:36.60]: Found: /bin/python --> /bin/python3.8
[INFO 2022-10-30 0:5:36.60]: Found: /bin/python2 --> /bin/python2.7
[INFO 2022-10-30 0:5:36.61]: Found: /bin/python2.7 --> /bin/python2.7
[INFO 2022-10-30 0:5:36.71]: Found: /bin/python3 --> /bin/python3.8
[DEBUG 2022-10-30 0:5:36.71]: Workspace Virtual Environment: [added] /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel/bin/python
[DEBUG 2022-10-30 0:5:36.71]: Workspace Virtual Environment: [skipped] /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel/bin/python3
[DEBUG 2022-10-30 0:5:36.71]: Workspace Virtual Environment: [skipped] /home/runner/work/vscode-jupyter/vscode-jupyter/src/test/datascience/.venvnokernel/bin/python3.10
[INFO 2022-10-30 0:5:36.76]: Found: /bin/python3.8 --> /bin/python3.8
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-environmentsFeatures relating to handling interpreter environmentsFeatures relating to handling interpreter environmentsbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked onReady to be worked onneeds spikeLabel for issues that need investigation before they can be worked on.Label for issues that need investigation before they can be worked on.verifiedVerification succeededVerification succeeded
Activity
[-]Python Extension API incorrectly triggers 'remote'[/-][+]Python Extension API incorrectly triggers 'remove' event [/+]DonJayamanne commentedon Nov 30, 2022
Job https://github.com/microsoft/vscode-jupyter/actions/runs/3579027060
VS Code logs (with Pythono output) https://github.com/microsoft/vscode-jupyter/suites/9575009837/artifacts/456041143
Jupyter logs can be found here https://github.com/microsoft/vscode-jupyter/actions/runs/3579027060/jobs/6019778068
I'm uploading the two logs here separately
DonJayamanne commentedon Dec 7, 2022
Running into this very often,
we get an event for remoted and immediate after an event for added
Sometimes it takes longer to get the added
DonJayamanne commentedon Dec 21, 2022
Still running into this on CI
This is most likely the cause of the bug that users are also running into microsoft/vscode-jupyter#11747
Kartik Raj (@karrtikr) do you have an update on this bug, we're running into this issue very often on CI and I believe our users too are running into this issue on the stable release and having issues running code in notebooks.
karrtikr commentedon Dec 22, 2022
I'll try to have a look today. Meanwhile you can work around this issue at Jupyter's end by selectively ignoring
removeevents ifresolveEnvironmentAPI for the event does not returnundefined.karrtikr commentedon Dec 22, 2022
I have created a PR #20424 which should hopefully take care of this, leaving this open so you can verify. Happy holidays!
13 remaining items
karrtikr commentedon Jan 24, 2023
Strange, 'remove' event is only fired after the environment is removed from cache, so 'resolveEnvironment' should ideally be returning 'undefined'.
Maybe there's some other caching that's going on.
DonJayamanne commentedon Feb 10, 2023
Kartik Raj (@karrtikr) just wanted to check if there was any progress on this.
I'm curious what
needs-spikemeans, does that mean this iteration you are only going to investigate this and resolve this the next iteration?If this isn't resolved for this iteration or cannot be resolved, then we might want to add some work around in the Jupyter extension.
This is because when such events get fired, notebooks break completely (i.e. user could be running some code and then all of a sudden everything could crash just because of this invalid event).
karrtikr commentedon Feb 10, 2023
We've other priority items that are being worked on right now, but we should be able to tackle this in this iteration as well. But given this has a simple workaround, please use that meanwhile.
It just means the next step is to investigate, we can resolve this immediately after in this iteration.
brettcannon commentedon Feb 10, 2023
FYI all of our "needs" labels are scoped to the issue, not to a specific iteration; it just records what is keeping the issue open.
DonJayamanne commentedon Feb 10, 2023
Thanks for the clarification
karrtikr commentedon Mar 1, 2023
I'm not able to reproduce this issue on Jupyter CI, confirmed after removing the workaround which was added. No tests fails, and I checked verbose logging to ensure that no
removeevents are being fired.DonJayamanne commentedon Mar 1, 2023
please note it was flaky, it wasn’t something that happened 100% of the time
I would suggest running the tests at least 10-20 times
karrtikr commentedon Mar 1, 2023
Okay I'll try it a few more times, I have added additional logging in the Python extension to diagnose in case this happens again.
karrtikr commentedon Mar 2, 2023
Able to repro it finally after running 10 runs concurrently 😄 Reason
removeevents were being fired was that running those interpreters was failing on CI due to timeout error (probably because of CPU load). So increased timeout from 15s to 30s on CI which seemed to have solved the problem.The cause of this issue was different than what was originally reported in the issue.