Skip to main content

Debugging runs in an IDE

To stop at a breakpoint in your run() function, debug one run: qa run on one input, as a Python module, in your IDE. Debugging qa batch doesn't work: its runs execute in other processes (with --runner local), or on other machines (with a cluster's runner), where your debugger can't follow.

Find the run's command​

Take the qa run command of the run you want to debug:

  • From a batch: qa --dryrun batch ci prints each run's command, and its output directory, without running anything. In the detector's project:

    qa --dryrun batch ci
    qa --configuration fp32:size-320 run --input "slices/indoor"
    /home/arjun/detector/output/7622c337-20/slices-indoor
    qa --configuration fp32:size-320 run --input "slices/outdoor"
    /home/arjun/detector/output/7622c337-20/slices-outdoor
    ...

    qa batch ci --list prints the same as JSON, with each run's command.

  • From a CI run: the first line of its log, in the web app's Logs view, is its qa run command.

Then give your IDE the arguments that come after qa.

VS Code​

Add a configuration to .vscode/launch.json (Run > Add Configuration...):

.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "qa run",
"type": "debugpy",
"request": "launch",
"module": "qaboard",
"cwd": "${workspaceFolder}",
"args": ["--configuration", "int8:size-320", "run", "--input", "slices/small-objects"]
}
]
}
  • module is qaboard: VS Code runs python -m qaboard, which is qa.
  • args are the arguments after qa. Debug a run, not a batch.
  • cwd is the folder with your qaboard.yaml.
caution

Don't start args with "--": qa treats everything after -- as arguments forwarded to your code, so the command would be ignored.

See VS Code's Python debugging docs for the other options.

PyCharm​

In Run > Edit Configurations..., add a Python configuration:

  1. In the script/module selector, choose Module, not Script, and enter qaboard.
  2. Parameters: the arguments after qa, like --configuration int8:size-320 run --input slices/small-objects. Debug a run, not a batch.
  3. Working directory: the folder with your qaboard.yaml.

Then start it with Debug: PyCharm stops at the breakpoints in your run().

tip

If qa complains about the locale, add the environment variables LC_ALL=en_US.utf8 and LANG=en_US.utf8 to the configuration.