Dynamic Static Inputs¶
The title of this page is a perfectly legit oxymoron in StepUp: it is possible to declare a static input file and then amend the same step with that file as a dynamic input, all in the same script. It is a special case of Dynamic Dependencies, which is occasionally useful. As of StepUp 1.2.0, this is allowed and no longer treated as a cyclic dependency.
For example, plan.py may read a configuration file to decide which steps to add to the workflow.
Hence, the config file is a static input to the workflow.
Since StepUp schedules the top-level ./plan.py step without initial inputs,
you have to use amend() to inform StepUp of this dependency.
Whenever you change the config file, StepUp will re-run ./plan.py to update the workflow.
Example¶
Create the following plan.py, which declares a static file,
amends the step with that file as a dynamic input,
and then opens it to print it to the standard output.
#!/usr/bin/env python3
from stepup.core.api import amend, static
static("config.txt")
amend(inp="config.txt")
with open("config.txt") as fh:
print(fh.read().strip())
Also create a config.txt file with some contents.
In more realistic scenarios, config.txt may be used to decide which steps to add etc.
For a more elaborate example, take a look at the
plan.py
that is used to run all tutorial examples.
Make plan.py executable and run it as follows:
You should get the following terminal output:
DIRECTOR │ Listening on /tmp/stepup-########/director (StepUp Core 4.0.0)
STARTUP │ (Re)initialized boot script
PHASE │ build
START │ ./plan.py
SUCCESS │ ./plan.py
─────────────────────────────── Standard output ────────────────────────────────
This is a config file.
────────────────────────────────────────────────────────────────────────────────
DIRECTOR │ Ran 1 job(s).
DIRECTOR │ Trying to remove 0 deletable file(s) and empty director(y|ies)
DIRECTOR │ See you!