facebookresearch / dora

Dora is an experiment management framework. It expresses grid searches as pure python files as part of your repo. It identifies experiments with a unique hash signature. Scale up to hundreds of experiments without losing your sanity.
MIT License
262 stars 24 forks source link

Is there any way to use the Debugger of VSCode while using "dora run"? #56

Closed sakemin closed 9 months ago

sakemin commented 10 months ago

❓ Questions

Is it possible to use VSCode Debugger with dora run command for debugging python codes?

adefossez commented 10 months ago

I know you can run the python debugger python3 -m pdb -c c -m dora run [other args].

Seems like something like that would work for the launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "dora",
            "args": ["run"],
            "justMyCode": true
        }
    ]
}
davlar1 commented 10 months ago

I still can't get the flasy cifar example to run with dora in vscode debugger. My launch.json is:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            //"program": "dora",
            "module": "dora",
            "args": [                
                "-P", "${workspaceFolder}/flashy-main/examples/cifar/", "run"                
                ],
        },        
    ]
}

And the terminal output from the vscode debugger is:

dgr2@ubuntudtdgr2:/storage/projects/misc/ml/flashy$ cd /storage/projects/misc/ml/flashy ; /usr/bin/env /storage/projects/venv/pyflashy/bin/python /home/dgr2/.vscode-server/extensions/ms-python.python-2023.16.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 53109 -- -m dora -P /storage/projects/misc/ml/flashy/flashy-main/examples/cifar/ run INFO:dora.utils:Could not import module /storage/projects/misc/ml/flashy/flashy-main/examples/cifar/.train Traceback (most recent call last): File "/storage/projects/venv/pyflashy/lib/python3.9/site-packages/dora/utils.py", line 77, in import_or_fatal return importlib.import_module(module_name) File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 972, in _find_and_load_unlocked File "", line 228, in _call_with_frames_removed File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 984, in _find_and_load_unlocked ModuleNotFoundError: No module named '/storage/projects/misc/ml/flashy/flashy-main/examples/cifar/' FATAL: Failed to import module /storage/projects/misc/ml/flashy/flashy-main/examples/cifar/.train.

i.e. it seems to be looking for a ...examples/cifar/.train module - any ideas what I need exactly to put in the launch.json ? Thanks.

adefossez commented 10 months ago

-P doesn't expect a file path but the name of the python package. The package must be importable from the current path, either through setting PYTHONPATH or running from the folder /storage/projects/misc/ml/flashy/flashy-main/examples/.