Skip to content

Amending Static Inputs

Occasionally, it may be convenient to declare a static file and then use it as input in the same script. As of StepUp 1.2.0, this is allowed and no longer treated as a cyclic dependency.

Example

Create the following plan.py, which declares a static file, amends it as input, and then opens it to print it to the standard output.

#!/usr/bin/env python
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:

chmod +x plan.py
stepup -n -w1

You should get the following terminal output:

  DIRECTOR │ Listening on /tmp/stepup-########/director
  DIRECTOR │ Launched worker 0
     PHASE │ run
     START │ ./plan.py
   SUCCESS │ ./plan.py
─────────────────────────────── Standard output ────────────────────────────────
This is a config file.
────────────────────────────────────────────────────────────────────────────────
  WORKFLOW │ Dumped to .stepup/workflow.mpk.xz
  DIRECTOR │ Stopping workers.
  DIRECTOR │ See you!