Args¶
NOTE:
The source code for the examples below can be found on GitHub.
If you pass any arguments to the dstack run
command, they can be accessed from the workflow YAML file via
the ${{ run.args }}
expression.
Create the following Python script:
import sys
if __name__ == '__main__':
print(sys.argv)
Then, define the following workflow YAML file:
workflows:
- name: hello-args
provider: bash
commands:
- python args/hello-arg.py ${{ run.args }}
Run it locally using dstack run
and passing "Hello, world!"
as an argument:
$ dstack run hello-arg "Hello, world!"
NOTE:
It supports any arguments except those that are reserved for the dstack run
command.