Working Directory¶
Every step is executed in a working directory, which you can specify when creating a step.
If the arguments inp, out and vol contain relative paths,
they are assumed to be relative to the working directory.
Warning
StepUp assumes that the current working directory is not changed
between importing any stepup module and calling functions from stepup.core.api.
For example, calling os.chdir() inside a plan.py (or before a static() or step()
call) makes the relative paths you pass ambiguous,
because StepUp resolves them against the directory it recorded at import time.
Instead of changing directory, pass paths relative to the step’s workdir argument.
Example¶
Example source files: docs/getting_started/workdir/
Create a top-level plan.py as follows:
#!/usr/bin/env python3
from stepup.core.api import run
run("echo 'a friendly file' > ${out}", shell=True, workdir="out/", out="hello.txt")
Make the scripts executable and run everything as follows:
Expected Terminal Output:
DIRECTOR │ Listening on /tmp/stepup-########/director (StepUp Core 3.2.3.post54)
STARTUP │ (Re)initialized boot script
PHASE │ build
START │ ./plan.py
SUCCESS │ ./plan.py
START │ echo 'a friendly file' > hello.txt # wd=out
SUCCESS │ echo 'a friendly file' > hello.txt # wd=out
DIRECTOR │ Trying to delete 0 outdated output(s)
DIRECTOR │ See you!
This will create an output file out/hello.txt
Further Reading¶
-
The
step()function and related functions that usestep()internally (run(),plan(),call(), …) all return aStepInfoobject, which may be used for defining follow-up steps. TheStepInfoobjects follow the same convention: theirinp,outandvolattributes are lists of paths. If these are relative paths, they are relative to thestep_info.workdirattribute. Consult the section StepInfo Objects for more details. -
In advanced workflows, the HERE and ROOT variables can be convenient to construct relative paths based on the current working directory.