-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Debugging DVC interactively
While debugging DVC, being a command-line application, you may need to change the command quite often. This might need you to change the arguments repeatedly which is cumbersome. The following guide walks you through how to debug it interactively in VSCode with minimal effort.
- Install Python Extension for VSCode if you haven't already.
- Run
pip install debugpy
. Please understand thatdebugpy
should be installed in the same environment as DVC is installed in. - Open "Run and Debug" in the VSCode from the sidebar.
- Select "Python" and then "Remote Attach".
- Enter the hostname as it is (i.e. "localhost") and then set the port.
This should create a .vscode/launch.json
file similar to the following.
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
}
]
}
-
Set the breakpoints you want. If you are unsure where to set, set it at the top-level with the command-runner.
-
Run the command that you want to debug in the terminal (any terminal, not just vscode :) ).
python -m debugpy --wait-for-client --listen {port} -m dvc {command}
eg: for debugging
dvc push
and debugger running in port 5678:python -m debugpy --wait-for-client --listen 5678 -m dvc push
It won't start running till we start the debugger.
-
From the "Run and Debug", run the appropriate debugger config ("Python: Remote Attach" in above).
Happy debugging!!!