microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.27k stars 280 forks source link

Debug Cell option disappears arbitrarily #15695

Closed epicwhale closed 1 month ago

epicwhale commented 3 months ago

Applies To

What happened?

Sometimes it shows the dropdown arrow with Debug option... image

And sometimes it does not... image

This is quite flaky and I can't figure out what's causing it.. pasted logs below

VS Code Version

Version: 1.90.0-insider Commit: 0cd8d6ac480bc5b4e2a2d7f1eb87eaff9f7d47e1 Date: 2024-05-16T05:50:49.491Z Electron: 29.3.1 ElectronBuildId: 9464424 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.4.0

Jupyter Extension Version

v2024.4.2024042601 (pre-release)

Jupyter logs

20:50:04.740 [debug] KernelProcess error 40580: [IPKernelApp] ERROR | Exception in control handler:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 362, in process_control
    await result
  File "/usr/local/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 1039, in debug_request
    reply_content = await reply_content
                    ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ipykernel/ipkernel.py", line 528, in do_debug_request
    return await self.debugger.process_request(msg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 740, in process_request
    self.stop()
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 445, in stop
    self.debugpy_client.disconnect_tcp_socket()
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 280, in disconnect_tcp_socket
    self.debugpy_stream.socket.disconnect(self._get_endpoint())
  File "zmq/backend/cython/socket.pyx", line 664, in zmq.backend.cython.socket.Socket.disconnect
zmq.error.ZMQError: No such file or directory

20:50:04.746 [debug] [Debug] to kernel: {"command":"threads","type":"request","seq":21}
20:50:04.747 [debug] [Debug] to kernel, mapped: {"command":"threads","type":"request","seq":21}
20:50:04.751 [debug] [Debug] response: {}
20:50:04.754 [debug] Executing silently Code (completed) = import os as _VSCODE_os\n_VSCODE_fileList = ["/tmp/ipykernel_40580/3891066634.py","/tmp/ipykernel_405 with 0 output(s)
20:50:04.754 [info] Ending debug session 5eae8558-0715-42fd-8d67-b71c32fb3d22
20:50:04.874 [info] Execution of code ms-toolsai.jupyter-4 completed in 70ms
20:50:07.284 [info] Ending debug session 5eae8558-0715-42fd-8d67-b71c32fb3d22
20:50:07.284 [info] Ending debug session 5eae8558-0715-42fd-8d67-b71c32fb3d22

Coding Language and Runtime Version

python 3.12

Language Extension Version (if applicable)

v2024.7.11371014 (pre-release)

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

epicwhale commented 3 months ago

Looks like there are others complaining about this in the vscode issues: https://github.com/microsoft/vscode/issues/150219

epicwhale commented 3 months ago

More logs if it helps debug:

07:39:07.151 [debug] [Debug] to kernel: {"command":"dumpCell","arguments":{"code":"# load codegen\n# await page.pause()"},"type":"request","seq":17}
07:39:07.151 [debug] [Debug] to kernel, mapped: {"command":"dumpCell","arguments":{"code":"# load codegen\n# await page.pause()"},"type":"request","seq":17}
07:39:07.155 [debug] [Debug] response: {"type":"response","request_seq":8,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/3891066634.py"}}
07:39:07.159 [debug] [Debug] response: {"type":"response","request_seq":9,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/1415183515.py"}}
07:39:07.160 [debug] [Debug] response: {"type":"response","request_seq":10,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/3067390400.py"}}
07:39:07.162 [debug] [Debug] response: {"type":"response","request_seq":11,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/1268468748.py"}}
07:39:07.165 [debug] [Debug] response: {"type":"response","request_seq":12,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/1697544791.py"}}
07:39:07.167 [debug] [Debug] response: {"type":"response","request_seq":13,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/1896725529.py"}}
07:39:07.169 [debug] [Debug] response: {"type":"response","request_seq":14,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/1035025455.py"}}
07:39:07.172 [debug] [Debug] response: {"type":"response","request_seq":15,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/944622012.py"}}
07:39:07.173 [debug] [Debug] response: {"type":"response","request_seq":16,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/258893771.py"}}
07:39:07.174 [debug] [Debug] response: {"type":"response","request_seq":17,"success":true,"command":"dumpCell","body":{"sourcePath":"/tmp/ipykernel_3985/1024466103.py"}}
07:39:07.191 [debug] [Debug] to kernel: {"command":"configurationDone","type":"request","seq":6}
07:39:07.191 [debug] [Debug] to kernel, mapped: {"command":"configurationDone","type":"request","seq":6}
07:39:07.195 [debug] [Debug] response: {"seq":6,"type":"response","request_seq":6,"success":true,"command":"configurationDone"}
07:39:07.199 [info] Handle Execution of Cells 1 for /workspace/backend/####.ipynb
07:39:07.200 [debug] Cell Index:1 sent to kernel
07:39:07.205 [debug] [Debug] to kernel: {"command":"threads","type":"request","seq":18}
07:39:07.205 [debug] [Debug] to kernel, mapped: {"command":"threads","type":"request","seq":18}
07:39:07.206 [debug] Start cell 1 execution @ 1715931547206 (clear output)
07:39:07.206 [debug] Kernel acknowledged execution of cell 1 @ 1715931547206
07:39:07.211 [debug] [Debug] response: {"seq":18,"type":"response","request_seq":18,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"MainThread"},{"id":2,"name":"Thread-1 (_watch_pipe_fd)"},{"id":3,"name":"Thread-2 (_watch_pipe_fd)"},{"id":4,"name":"IPythonHistorySavingThread"},{"id":5,"name":"asyncio_0"}]}}
07:39:07.298 [info] Cell 1 completed in 0.092s (start: 1715931547206, end: 1715931547298)
07:39:07.298 [debug] Cell 1 executed successfully
07:39:07.329 [debug] Executing silently Code (idle) = import os as _VSCODE_os\n_VSCODE_fileList = ["/tmp/ipykernel_3985/3891066634.py","/tmp/ipykernel_3985
07:39:07.341 [debug] [Debug] to kernel: {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":19}
07:39:07.341 [debug] [Debug] to kernel, mapped: {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":19}
07:39:07.346 [debug] [Debug] event: {"header":{"msg_id":"cfb61645-8cff287df7f2bc9a5a7d54b1_3985_223","msg_type":"debug_event","username":"~","session":"cfb61645-8cff287df7f2bc9a5a7d54b1","date":"2024-05-17T07:39:07.345643Z","version":"5.3"},"parent_header":{"date":"2024-05-17T07:39:07.341000Z","msg_id":"608110e5-e78e-4f70-b539-6193982b83aa","msg_type":"debug_request","session":"a872523a-429f-4eaf-870a-bdf5d2257aa1","username":"62ac7f5c-a327-4204-a29b-0fe904c38388","version":"5.2"},"metadata":{},"content":{"seq":19,"type":"event","event":"terminated"},"idents":[{"type":"Buffer","data":[107,101,114,110,101,108,46,50,50,55,97,50,48,52,56,45,102,98,100,102,45,52,97,100,52,45,97,100,48,48,45,100,98,51,102,50,53,100,102,102,49,101,98,46,100,101,98,117,103,95,101,118,101,110,116]}],"buffers":[],"channel":"iopub"}
07:39:07.356 [debug] [Debug] response: {"seq":20,"type":"response","request_seq":19,"success":true,"command":"disconnect"}
07:39:07.356 [debug] [Debug] to kernel: {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":20}
07:39:07.356 [debug] [Debug] to kernel, mapped: {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":20}
07:39:07.358 [debug] KernelProcess error 3985: [IPKernelApp] ERROR | Exception in control handler:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 362, in process_control
    await result
  File "/usr/local/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 1039, in debug_request
    reply_content = await reply_content
                    ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ipykernel/ipkernel.py", line 533, in do_debug_request
    return await self.debugger.process_request(msg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 740, in process_request
    self.stop()
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 445, in stop
    self.debugpy_client.disconnect_tcp_socket()
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 280, in disconnect_tcp_socket
    self.debugpy_stream.socket.disconnect(self._get_endpoint())
  File "_zmq.py", line 995, in zmq.backend.cython._zmq.Socket.disconnect
zmq.error.ZMQError: No such file or directory

07:39:07.374 [debug] Executing silently Code (completed) = import os as _VSCODE_os\n_VSCODE_fileList = ["/tmp/ipykernel_3985/3891066634.py","/tmp/ipykernel_3985 with 0 output(s)
07:39:07.374 [info] Ending debug session 8232e658-f9db-4d80-97ca-4bd2403c3cc1
07:39:07.526 [info] Execution of code ms-toolsai.jupyter-3 completed in 72ms
07:39:09.408 [info] Ending debug session 8232e658-f9db-4d80-97ca-4bd2403c3cc1
07:39:09.409 [info] Ending debug session 8232e658-f9db-4d80-97ca-4bd2403c3cc1
epicwhale commented 2 months ago

Just wondering if any luck with this one?

DonJayamanne commented 1 month ago

File "_zmq.py", line 995, in zmq.backend.cython._zmq.Socket.disconnect zmq.error.ZMQError: No such file or directory

Sorry for not getting back on this. I guess its obvious that you are still running into this issue.

Based on the above errors, there seems to be an issue with the installation of zmq. My suggestion is to create a virtual environment using the commands python -m venv .venv or the like. Then use that Environment as the kernel in the kernel picker and try using that for debugging (that will result in you being promtped to install ipykernel into that env and hopefully it will get installed correctly and resolve this issue)

epicwhale commented 1 month ago

@DonJayamanne hmm, so I am using VS Code with Dev Containers.. I'm not sure it makes sense to use a venv inside a dev container? also not sure how to redo the dev container specifications, etc to make a venv instead, just to get this to work? I am using the default python mcr.microsoft.com/devcontainers/python:1-3.12-bullseye

furthermore, I feel this issue gets exasperated when the kernel itself does not connect, and the restart button disappears, which is this issue - https://github.com/microsoft/vscode/issues/200896

So at times I'm not sure which issue is causing the other.

DonJayamanne commented 1 month ago

Thanks, going to try that container myself and see whats going on.

DonJayamanne commented 1 month ago

@epicwhale I just tried that image and selected the same Python enviornment and it works for me (after installing ipykernel) My suggestion is to try to re-install ipykernel or just re-build the container.

As for the issue with debug cell disappearing, lets close this issue as a duplicate of https://github.com/microsoft/vscode/issues/150219