What I’d really like to do is to be able to pass variables from the command line; i.e. where I run
rose suite-run
from. Is that possible?
Sure, Rose/Cylc support passing through Jinja2 variables from the command line.
suite.rc
#!Jinja2
[runtime]
[[mytask]]
script = rose task-run
[[[environment]]]
# translate jinja2 variable into environment variable
MY_VARIABLE={{ MY_VARIABLE }}
# the rose way
$ rose suite-run -S 'MY_VARIABLE=42' # note capital 'S'
# the cylc way
$ cylc run -s 'MY_VARIABLE=42' # note lower 's'
Note you can define default values in your suite configuration file which you can (optionally) override on the command line using -S
:
rose-suite.conf
[jinja2:suite.rc]
MY_VARIABLE=42
Note: If you are overriding variables often you many want to group commonly used options into files which you can turn on or off. Rose provides a mechanism for doing this called optional configurations, these work for suite and application configurations. See also the related ROSE_APP_OPT_CONF_KEYS and ROSE_SUITE_OPT_CONF_KEYS environment variables.