skip to Main Content

For management of my config files, I’m using Hydra which requires passing additional arguments using a plus and then an equal sign between the argument and its value, e.g.

python evaluate.py '+model_path="logs/fc/version_1/checkpoints/epoch=1-step=2.ckpt"'

Above I’m also using quotes to escape the equal signs in the value.

I want to pass this in vscode to launch.json to the args field; however, I don’t know how to do it properly because typically the argument and value parts are separated by a space and not an equal sign as for Hydra. So the following doesn’t work:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Current File",
      "type": "python",
      "request": "launch",
      "program": "${file}",
      "console": "integratedTerminal",
      "args" : ["+model_path", "logs/fc/version_1/checkpoints/epoch=1-step=2.ckpt"]
    }
  ]
}

How should I change args to get it right?

2

Answers


  1. Chosen as BEST ANSWER

    This may not be the most elegant solution but it works if we pass everything as a single argument (no comma inbetween) like this:

    "args" : ["+model_path='logs/fc/version_7/checkpoints/epoch=19-step=3700.ckpt'"]


  2. If you need to pass arguments to the Python interpreter, you can use the pythonArgs property.

    Use the following syntax:

    "pythonArgs": ["<arg 1>", "<arg 2>",...]
    

    If you pass paired arguments with args:

    "args" : ["--port", "1593"]
    

    There are more details on launch.json configuration here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search