sacred icon indicating copy to clipboard operation
sacred copied to clipboard

Sacred not compatible with ptvsd (the debugger used in VS Code)

Open maximilianigl opened this issue 7 years ago • 1 comments

When debugging a sacred experiment with Visual Studio Code, which uses the ptvsd debugger, the debugger crashes at the first breakpoint inside the experiment. So everything before the ex.automain decorated function works fine and breakpoints work. However, as soon as reaching a breakpoint inside the main function, the debugger crashes. Specifying the -d flag doesn't make a difference.

Example code:

from sacred import Experiment

ex = Experiment("test") # Breakpoint here works fine

@ex.automain
def main_function():
    print(1)
    print(2) # Breakpoint here crashes
    print(3)

Leads to following output with breakpoint at print(2)

env "PYTHONIOENCODING=UTF-8" "PYTHONUNBUFFERED=1" "PYTHONPATH=<home>/.vscode/extensions/ms-python.python-2018.8.0/pythonFiles/experimental/ptvsd" <home>/.pyenv/versions/anaconda3-4.3.0/bin/python -m ptvsd --host localhost --port 59042 <path_to_file>/test.py -d
cd <path_to_file> ; env "PYTHONIOENCODING=UTF-8" "PYTHONUNBUFFERED=1" "PYTHONPATH=<home>/.vscode/extensions/ms-python.python-2018.8.0/pythonFiles/experimental/ptvsd" <home>/.pyenv/versions/anaconda3-4.3.0/bin/python -m ptvsd --host localhost --port 59042 <path_to_file>/test.py -d
Backend TkAgg is interactive backend. Turning interactive mode on.
INFO - test - Running command 'main_function'
INFO - test - Started
1
Tcl_WaitForEvent: Notifier not initialized
[1]    45315 abort      env "PYTHONIOENCODING=UTF-8" "PYTHONUNBUFFERED=1"   -m ptvsd --host localhost

(where I shortened file paths with <...>)

On MacOS Sierra with the newest Visual Studio Code. Edit: Python 3.6 (Anaconda)

maximilianigl avatar Sep 16 '18 22:09 maximilianigl

This is troubling, and I currently don't have any idea what could cause this behavior. If you find any further hints, please let me know.

Qwlouse avatar Oct 22 '18 08:10 Qwlouse