Args¶
NOTE:
The source code of this example is available in the Playground.
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 usage/args/hello_args.py ${{ run.args }}
Run it using dstack run
and passing "Hello, world!"
as an argument:
$ dstack run hello-args "Hello, world!"
NOTE:
It supports any arguments except those that are reserved for the dstack run
command.