This tutorial walks you through using command keys.
Command keys allow you to specify and run different commands for an app.
Command keys can be used to specify different ways of running a particular app.
They work just like the default command for an app
but have to be specified explicitly as an option of
rose task-run
.
Create a new suite (or just a new directory somewhere - e.g. in your homespace) containing a blank rose-suite.conf and a suite.rc file that looks like this:
[cylc] UTC mode = True # Ignore DST [scheduling] [[dependencies]] graph = gather_ingredients => breadmaker [runtime] [[gather_ingredients]] script = sleep 10; echo 'Done' [[breadmaker]] script = rose task-run
In your suite directory create an app directory.
In the app directory create a new directory called breadmaker.
In the breadmaker directory create a rose-app.conf file that looks like this:
[command] default=sleep 10; echo 'fresh bread'
This sets up a simple suite that contains the following:
Save your changes and run the suite using rose suite-run.
Once it has finished use rose suite-log to view the suite log. In the page that appears, click the "out" link for the breadmaker task. In the page you are taken to you should see a line saying "fresh bread".
Open the rose-app.conf file and edit to look like this:
[command] default=sleep 10; echo 'fresh bread' make_dough=sleep 8; echo 'dough for later' timed_bread=sleep 15; echo 'fresh bread when you want it'
Save your changes and open up your suite.rc file. Alter the [[breadmaker]] task to look like this:
[[breadmaker]] script=rose task-run --command-key=make_dough
Save your changes and run the suite. If you inspect the output from the breadmaker task you should see the line "dough for later".
Edit the script
for the
[[breadmaker]] task to change the
command key to 'timed_bread'. Run the
suite and confirm the timed_bread
command has been run.
You have successfully made use of command keys to run alternate commands in an app.
Possible uses of command keys might be: