vscode-jupyter: Subprocess debugging not supported

Does this issue occur when all extensions are disabled?: Yes/No (N/A, requires the Python and Jupyter extensions)

  • VS Code Version: 1.66.2 (Universal) Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
  • OS Version: macOS Monterey (12.1)

Steps to Reproduce:

I admit that I don’t have any good intuition at this point if this is a bug with VS code, or if it’s a coincidence with some wonkiness in my Python environments, or what exactly is happening, but I truly don’t understand the behavior I’m observing.

My apologies for splitting the description over a few cells, but the stack traces are too long to fit in one post.

  1. A minimal example reproducing the bug (though I admit I can’t imagine in what that particular cell would cause this to fail) is available in the last cell of this notebook: https://github.com/guydav/simple-relational-reasoning/blob/quinn-epxanded/notebooks/BugReproduction.ipynb
  2. This cell successfully runs every conda environment I have on my machine (using both Python 3.8.2 and 3.9.7), but only successfully debugs in my base conda environment. In every other environment (including ones where debugging cells worked up until recently), debugging this cell throws the following error: “Invalid message: Session is already started” and offers to open launch.json.

Below is a full trace of the Jupyter output in verbose, cleared before attempting to debug the relevant cell, when it succeeds:

Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Info 16:26:05: Executing silently Code (completed) = import ipykernel\nprint(ipykernel.__version__)
Verbose 16:26:05: [Debug] to kernel: {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"Python Kernel Debug Adapter","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true},"type":"request","seq":1}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_520","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.175092Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_520","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.172000Z","msg_id":"a393516e-0822-4391-8ccc-4a99444fbeaa","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":1,"type":"event","event":"output","body":{"category":"telemetry","output":"ptvsd","data":{"packageVersion":"1.4.1"}}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_521","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.175495Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_521","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.172000Z","msg_id":"a393516e-0822-4391-8ccc-4a99444fbeaa","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":2,"type":"event","event":"output","body":{"category":"telemetry","output":"debugpy","data":{"packageVersion":"1.4.1"}}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":3,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDebuggerProperties":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsExceptionInfoRequest":true,"supportsExceptionOptions":true,"supportsFunctionBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsModulesRequest":true,"supportsSetExpression":true,"supportsSetVariable":true,"supportsValueFormattingOptions":true,"supportsTerminateDebuggee":true,"supportsGotoTargetsRequest":true,"supportsClipboardContext":true,"exceptionBreakpointFilters":[{"filter":"raised","label":"Raised Exceptions","default":false},{"filter":"uncaught","label":"Uncaught Exceptions","default":true}],"supportsStepInTargetsRequest":true}}
Verbose 16:26:05: [Debug] to kernel: {"command":"debugInfo","type":"request","seq":3}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"type":"response","request_seq":3,"success":true,"command":"debugInfo","body":{"isStarted":true,"hashMethod":"Murmur2","hashSeed":3339675911,"tmpFilePrefix":"/var/folders/h9/kzpqpksx6fq00v9d73x5j51c0000gn/T/ipykernel_25611/","tmpFileSuffix":".py","breakpoints":[],"stoppedThreads":[]}}
Verbose 16:26:05: [Debug] to kernel: {"command":"attach","arguments":{"type":"Python Kernel Debug Adapter","name":"BugReproduction.ipynb","request":"attach","justMyCode":true,"__mode":1,"__cellIndex":3,"__sessionId":"674c28d6-9c8b-44e2-814d-870c2021f3d7"},"type":"request","seq":2}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_528","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.201934Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_528","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":4,"type":"event","event":"debugpyWaitingForServer","body":{"host":"127.0.0.1","port":52928}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_529","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.204465Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_529","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":5,"type":"event","event":"initialized"},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_532","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.206936Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_532","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":8,"type":"event","event":"process","body":{"name":"/Users/guydavidson/opt/anaconda3/lib/python3.9/site-packages/ipykernel_launcher.py","systemProcessId":25611,"isLocalProcess":true,"startMethod":"attach"}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] response: {"seq":7,"type":"response","request_seq":2,"success":true,"command":"attach"}
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_533","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.207232Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_533","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":9,"type":"event","event":"thread","body":{"reason":"started","threadId":1}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_534","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.207408Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_534","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":10,"type":"event","event":"thread","body":{"reason":"started","threadId":2}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_535","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.207630Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_535","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":11,"type":"event","event":"thread","body":{"reason":"started","threadId":3}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_536","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.207815Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_536","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":12,"type":"event","event":"thread","body":{"reason":"started","threadId":4}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_537","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.207972Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_537","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":13,"type":"event","event":"thread","body":{"reason":"started","threadId":5}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] event: {"header":{"msg_id":"a5f90694-7be1056687156ded0a44d86a_538","msg_type":"debug_event","username":"guydavidson","session":"a5f90694-7be1056687156ded0a44d86a","date":"2022-05-03T20:26:05.208233Z","version":"5.3"},"msg_id":"a5f90694-7be1056687156ded0a44d86a_538","msg_type":"debug_event","parent_header":{"date":"2022-05-03T20:26:05.199000Z","msg_id":"1e20aa47-ba4c-4074-ad30-932510670ed9","msg_type":"debug_request","session":"d91e69c7-1073-4444-9bbe-75ee20785bba","username":"","version":"5.2"},"metadata":{},"content":{"seq":14,"type":"event","event":"thread","body":{"reason":"started","threadId":6}},"buffers":[],"channel":"iopub"}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"models.py","path":"/Users/guydavidson/projects/simple-relational-reasoning/simple_relational_reasoning/embeddings/models.py"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":4}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"NewCentroidAnalysis.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/NewCentroidAnalysis.ipynb#ch0000003"},"lines":[15],"breakpoints":[{"line":15}],"sourceModified":false},"type":"request","seq":5}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"quinn_objects.py","path":"/Users/guydavidson/projects/simple-relational-reasoning/simple_relational_reasoning/datagen/quinn_objects.py"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":6}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"QuinnCentroidsAnalysis.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/QuinnCentroidsAnalysis.ipynb#ch0000004"},"lines":[58],"breakpoints":[{"line":58}],"sourceModified":false},"type":"request","seq":7}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"QuinnDataAnalysis.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/QuinnDataAnalysis.ipynb#ch0000032"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":8}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"QuinnDataAnalysis.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/QuinnDataAnalysis.ipynb#ch0000015"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":9}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"QuinnEmbeddingDebugging.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/QuinnEmbeddingDebugging.ipynb#ch0000004"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":10}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"QuinnEmbeddingTask.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/QuinnEmbeddingTask.ipynb#ch0000065"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":11}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"QuinnStimuliDemo.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/QuinnStimuliDemo.ipynb#ch0000015"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":12}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"QuinnStimuliDemo.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/QuinnStimuliDemo.ipynb#ch0000007"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":13}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"run_embeddings.py","path":"/Users/guydavidson/projects/simple-relational-reasoning/run/run_embeddings.py"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":14}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"stimuli.py","path":"/Users/guydavidson/projects/simple-relational-reasoning/simple_relational_reasoning/embeddings/stimuli.py"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":15}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"task.py","path":"/Users/guydavidson/projects/simple-relational-reasoning/simple_relational_reasoning/embeddings/task.py"},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":16}
Verbose 16:26:05: [Debug] to kernel: {"command":"setBreakpoints","arguments":{"source":{"name":"triplets.py","path":"/Users/guydavidson/projects/simple-relational-reasoning/simple_relational_reasoning/embeddings/triplets.py"},"lines":[185],"breakpoints":[{"line":185,"condition":"-target_horizontal_margin >= target_horizontal_margin - target_distance"}],"sourceModified":false},"type":"request","seq":17}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] response: {"seq":15,"type":"response","request_seq":4,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] response: {"seq":16,"type":"response","request_seq":5,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"verified":false,"message":"Breakpoint in file that does not exist.","source":{"name":"NewCentroidAnalysis.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/NewCentroidAnalysis.ipynb#ch0000003"},"line":15}]}}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] response: {"seq":17,"type":"response","request_seq":6,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: [Debug] response: {"seq":18,"type":"response","request_seq":7,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"verified":false,"message":"Breakpoint in file that does not exist.","source":{"name":"QuinnCentroidsAnalysis.ipynb","path":"vscode-notebook-cell:/Users/guydavidson/projects/simple-relational-reasoning/notebooks/QuinnCentroidsAnalysis.ipynb#ch0000004"},"line":58}]}}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":19,"type":"response","request_seq":8,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] response: {"seq":20,"type":"response","request_seq":9,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] response: {"seq":21,"type":"response","request_seq":10,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: [Debug] response: {"seq":22,"type":"response","request_seq":11,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] response: {"seq":23,"type":"response","request_seq":12,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":24,"type":"response","request_seq":13,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] response: {"seq":25,"type":"response","request_seq":14,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":26,"type":"response","request_seq":15,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":27,"type":"response","request_seq":16,"success":true,"command":"setBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":28,"type":"response","request_seq":17,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"verified":true,"id":1,"source":{"name":"triplets.py","path":"/Users/guydavidson/projects/simple-relational-reasoning/simple_relational_reasoning/embeddings/triplets.py"},"line":185}]}}
Verbose 16:26:05: [Debug] to kernel: {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":18}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":29,"type":"response","request_seq":18,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
Verbose 16:26:05: [Debug] to kernel: {"command":"setExceptionBreakpoints","arguments":{"filters":["uncaught"]},"type":"request","seq":19}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] to kernel: {"command":"threads","type":"request","seq":20}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":30,"type":"response","request_seq":19,"success":true,"command":"setExceptionBreakpoints"}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":31,"type":"response","request_seq":20,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"MainThread"},{"id":2,"name":"Thread-6"},{"id":3,"name":"Thread-7"},{"id":4,"name":"IPythonHistorySavingThread"},{"id":5,"name":"Thread-2"},{"id":6,"name":"Thread-8"}]}}
Info 16:26:05: Executing silently Code (idle) = import debugpy\ndebugpy.debug_this_thread()
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Info 16:26:05: Executing silently Code (completed) = import debugpy\ndebugpy.debug_this_thread()
Verbose 16:26:05: [Debug] to kernel: {"command":"dumpCell","arguments":{"code":"import os\nimport sys\nsys.path.append(os.path.abspath('.'))\nsys.path.append(os.path.abspath('..'))\nsys.path.append(os.path.abspath('../run'))\n\nfrom collections import defaultdict\nimport itertools\nimport numpy as np\nimport matplotlib\nimport matplotlib.pyplot as plt\nfrom scipy import stats\nimport typing\nimport pandas as pd\nfrom tqdm.notebook import tqdm\nimport tabulate\n\nfrom torchvision.transforms import functional as F\n\nfrom IPython.display import display, Markdown\n\nfrom simple_relational_reasoning.embeddings.stimuli import build_differet_shapes_stimulus_generator, build_split_text_stimulus_generator, build_random_color_stimulus_generator,\\\n    find_non_empty_indices, EMPTY_TENSOR_PIXEL\nfrom simple_relational_reasoning.embeddings.triplets import QuinnTripletGenerator, ABOVE_BELOW_RELATION, BETWEEN_RELATION\nfrom simple_relational_reasoning.embeddings.visualizations import filter_and_group, DEFAULT_TEXT_KWARGS, save_plot"},"type":"request","seq":22}
Verbose 16:26:05: [Debug] to kernel: {"command":"dumpCell","arguments":{"code":"BASELINE_TRIPLET_KWARGS = dict(n_target_types=2, extra_diagonal_margin=0)\n\ndistance_endpoints_dict = {\n    (False, False): (30, 80),\n    (True, False): (60, 120),\n    (True, True): (40, 80),  \n}\n\ndef parse_above_below_condition(df):\n    above_below_types = []\n\n    for _, (relation, two_refs, adjacent_refs) in \\\n        df.loc[:, ['relation', 'two_reference_objects', 'adjacent_reference_objects']].iterrows():\n        a_b_type = None\n\n        if relation == 'above_below':\n            if not two_refs:\n                a_b_type = 'one_reference'\n\n            elif adjacent_refs:\n                a_b_type = 'adjacent_references'\n\n            else:\n                a_b_type = 'gapped_references'\n\n        above_below_types.append(a_b_type)\n\n    return df.assign(above_below_type=above_below_types)\n\n\nGENERATOR_NAMES = ('color bar', 'split text', 'random colors')\n\n\ndef create_stimulus_generators_and_names(names=GENERATOR_NAMES, seed=None, **kwargs):\n    rng = np.random.default_rng(seed if seed is not None else np.random.randint(0, 2**32))\n\n    generators = (\n        build_differet_shapes_stimulus_generator(rng=rng, **kwargs), \n        \n        build_split_text_stimulus_generator(\n            # reference_box_size=10,\n            # total_reference_size=(10, 140), n_reference_patches=8,\n            # reference_patch_kwargs=dict(ylim=(-70, 70)),\n            rng=rng, **kwargs),\n        build_random_color_stimulus_generator(rng=rng, **kwargs)\n    )\n    \n    return zip(generators, names)"},"type":"request","seq":23}
Verbose 16:26:05: [Debug] to kernel: {"command":"dumpCell","arguments":{"code":"DATA_PATH = 'centroid_sizes.csv'\nLIST_COLUMNS = [\n    'row_centroids', 'col_centroids', \n    'first_non_empty_row', 'last_non_empty_row', \n    'first_non_empty_col', 'last_non_empty_col'\n]\nCOLUMNS = [\n    'relation', 'two_reference_objects', \n    'adjacent_reference_objects', 'transpose', \n    'n_habituation_stimuli', 'rotate_angle', 'stimulus_generator'\n] + LIST_COLUMNS\nN_examples = 100\nANGLES = [0, 30, 45, 60, 90, 120, 135, 150]\n\nOPTION_SET = (\n    (ABOVE_BELOW_RELATION, BETWEEN_RELATION),\n    (False, True),\n    (False, True),\n    (False, True),\n    [1, 4],\n    ANGLES\n) \n"},"type":"request","seq":24}
Verbose 16:26:05: [Debug] to kernel: {"command":"dumpCell","arguments":{"code":"generate_data = True\nif generate_data:\n    total_options = np.prod([len(v) for v in OPTION_SET])\n    option_iter = itertools.product(*OPTION_SET)\n\n    data_rows = []\n\n    for relation, two_reference_objects, adjacent_reference_objects, transpose, n_habituation_stimuli, rotate_angle in tqdm(option_iter, total=total_options):\n        if (relation == ABOVE_BELOW_RELATION) and not two_reference_objects and adjacent_reference_objects:\n            continue\n\n        if (relation == BETWEEN_RELATION) and ((not two_reference_objects) or adjacent_reference_objects):\n            continue\n\n        distance_endpoints = distance_endpoints_dict[(two_reference_objects, adjacent_reference_objects)]\n\n        for stimulus_generator, generator_name in create_stimulus_generators_and_names(rotate_angle=rotate_angle):\n            triplet_generator = QuinnTripletGenerator(stimulus_generator, distance_endpoints,\n                relation=relation, two_reference_objects=two_reference_objects,\n                adjacent_reference_objects=adjacent_reference_objects, \n                transpose=transpose,\n                n_habituation_stimuli=n_habituation_stimuli,\n                track_centroids=True,\n                **BASELINE_TRIPLET_KWARGS)\n\n            triplets = triplet_generator(N_examples, normalize=False)\n            non_empty_tuples = [find_non_empty_indices(t, empty_value=EMPTY_TENSOR_PIXEL, color_axis=0) for t in triplets.view(-1, *triplets.shape[2:])]\n            del triplets\n            row_centroids, col_centroids = zip(*triplet_generator.stimulus_centroids)\n            row_centroids = list(row_centroids)\n            col_centroids = list(col_centroids)\n\n            first_non_empty_row, last_non_empty_row, first_non_empty_col, last_non_empty_col = zip(*non_empty_tuples)\n            first_non_empty_row = [i.item() for i in first_non_empty_row]\n            last_non_empty_row = [i.item() for i in last_non_empty_row]\n            first_non_empty_col = [i.item() for i in first_non_empty_col]\n            last_non_empty_col = [i.item() for i in last_non_empty_col]\n            \n            row = [relation, two_reference_objects, adjacent_reference_objects, transpose,\n                n_habituation_stimuli, rotate_angle, generator_name, \n                row_centroids, col_centroids, \n                first_non_empty_row, last_non_empty_row, first_non_empty_col, last_non_empty_col\n            ]\n            data_rows.append(row)\n\n            del triplet_generator\n            del stimulus_generator\n\n    \n    data_df = pd.DataFrame(data_rows, columns=COLUMNS)\n    data_df = parse_above_below_condition(data_df)\n    data_df.to_csv(DATA_PATH, index=False)\n\nelse:\n    data_df = pd.read_csv(DATA_PATH, converters={col: pd.eval for col in LIST_COLUMNS})    \n    data_df = data_df.assign(**{col: data_df[col].apply(list) for col in LIST_COLUMNS})\n    data_df = data_df.assign(relation_and_type=data_df.above_below_type)\n    data_df.relation_and_type[data_df.relation_and_type.isna()] = 'between'\n    \n\ndata_df.head() \n\n"},"type":"request","seq":25}
Verbose 16:26:05: [Debug] to kernel: {"command":"dumpCell","arguments":{"code":""},"type":"request","seq":26}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"type":"response","request_seq":22,"success":true,"command":"dumpCell","body":{"sourcePath":"/var/folders/h9/kzpqpksx6fq00v9d73x5j51c0000gn/T/ipykernel_25611/3409709466.py"}}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"type":"response","request_seq":23,"success":true,"command":"dumpCell","body":{"sourcePath":"/var/folders/h9/kzpqpksx6fq00v9d73x5j51c0000gn/T/ipykernel_25611/2127228247.py"}}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"type":"response","request_seq":24,"success":true,"command":"dumpCell","body":{"sourcePath":"/var/folders/h9/kzpqpksx6fq00v9d73x5j51c0000gn/T/ipykernel_25611/3824027068.py"}}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: [Debug] response: {"type":"response","request_seq":25,"success":true,"command":"dumpCell","body":{"sourcePath":"/var/folders/h9/kzpqpksx6fq00v9d73x5j51c0000gn/T/ipykernel_25611/1045445394.py"}}
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"type":"response","request_seq":26,"success":true,"command":"dumpCell","body":{"sourcePath":"/var/folders/h9/kzpqpksx6fq00v9d73x5j51c0000gn/T/ipykernel_25611/3990065800.py"}}
Verbose 16:26:05: [Debug] to kernel: {"command":"configurationDone","type":"request","seq":21}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":21,"type":"response","request_seq":21,"success":true,"command":"configurationDone"}
Verbose 16:26:05: VSCodeNotebookController::handleExecution, Class name = M (started execution)
Info 16:26:05: Execute Cells request 3
Info 16:26:05: Execute Cell 3 ~/projects/simple-relational-reasoning/notebooks/BugReproduction.ipynb
Verbose 16:26:05: [Debug] to kernel: {"command":"threads","type":"request","seq":27}
Verbose 16:26:05: IKernel Status change to busy
Verbose 16:26:05: IKernel Status change to idle
Verbose 16:26:05: [Debug] response: {"seq":32,"type":"response","request_seq":27,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"MainThread"},{"id":2,"name":"Thread-6"},{"id":3,"name":"Thread-7"},{"id":4,"name":"IPythonHistorySavingThread"},{"id":5,"name":"Thread-2"},{"id":6,"name":"Thread-8"}]}}
Verbose 16:26:05: IKernel Status change to busy```

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 61 (29 by maintainers)

Commits related to this issue

Most upvoted comments

Try to debug cell with multiprocess will make current notebook idle forever, really need a quick fix.

I get the same issue - is there a plan to get this fixed? This makes debugging something with e.g PyTorch data loaders impossible through VSCode Jupyter. Could we at least have a fix for the hanging debugger?

I am also facing this issue. After trying to debug my code for several hours. I ended in this thread and realised the root cause is with the Jupyter debugging extension breaks when multiprocessing is involved. We really need to fix this ASAP.

Now the subprocess hangs because the debugpyAttach message doesn’t pass from vscode-jupyter to vscode-python extensions. In my case that hangs the parent process as well (as it’s waiting on the subprocess)

I think you need to call debugpy.configure(subProcess=False) before starting debugging now.

Here’s the code in ipykernel that starts debugging- it doesn’t take arguments to configure debugpy- https://github.com/ipython/ipykernel/blob/aa53dcef1a282cba7dbd06d0715252ad10a9987c/ipykernel/debugger.py#L422

I also found this but I can’t find which context it’s used- https://github.com/microsoft/vscode-jupyter/blob/2023.02.100/src/interactive-window/debugger/interactiveWindowDebugger.node.ts#L47

I’m from the – ‘debug adapter’ error in jupyter notebook – issue int19h mentioned above. I tried adding “subProcess”: false to the launch.json for the current project. I continue to get the ‘debug adapter’ error.

Jupyter sessions don’t use the launch.json unfortunately. They generate their own configuration in memory. Example: https://github.com/microsoft/vscode-jupyter/blob/91a3a3ab86f726b516c9bb679200621d99055c82/src/notebooks/debugger/debuggingManager.ts#L163

Until this is supported, I would suggest explicitly setting "subProcess": false for Jupyter sessions to avoid subprocess attach error messages.

From your original log, looks like this fails when debugpy issues the debugpyAttach request to attach to a subprocess. When I run this code there is no subprocess involved. Any idea why tqdm would start a subprocess for you but not for me?

It makes sense that we won’t yet support this scenario, but I don’t see an existing issue. Simpler code to reproduce:

In a cell:

import subprocess

print("start")
subprocess.run(["python", "a.py"])
print("end")

In a.py

import time

print("a start")
time.sleep(1)
print("a end")

I guess we need to rewrite the debugpyAttach request to do a normal “python” type attach.

The env I created was just to test the Lava framework tutorials. Here is how I created that env, following the recommendations in the lava README to use poetry.

conda create -n lava python=3
conda activate lava
git clone https://github.com/lava-nc/lava
cd lava/
pip install poetry
poetry config virtualenvs.in-project true
poetry install
pip install ipykernel

Then you can try to debug one of the notebooks in the tutorials folder. In my case, I was attempting to debug cell 5 of the tutorials/in_depth/tutorial03_process_models.ipynb notebook