Static Files¶
When steps use input files written by you, this must be explicitly stated in plan.py
by declaring the human-written files as static files.
This informs StepUp that such files are readily available,
unlike files that are outputs of steps that still need to be executed.
Example¶
Example source files: docs/getting_started/static_files/
Create a file limerick.txt
with the following contents:
A physicist named Erwin, quite shrewd,
Put a feline in a box rather crude.
With a vial of doom,
And radioactive gloom,
The poor cat's fate, both alive and subdued!
Also create the following plan.py
:
#!/usr/bin/env python3
from stepup.core.api import runsh, static
static("limerick.txt")
runsh("nl ${inp} > ${out}", inp="limerick.txt", out="numbered.txt")
The static()
function declares a static file,
i.e. one that you have created.
Make the plan executable and run it with StepUp as follows:
You should get the following output:
DIRECTOR │ Listening on /tmp/stepup-########/director (StepUp 3.0.0)
STARTUP │ (Re)initialized boot script
DIRECTOR │ Launched worker 0
PHASE │ run
START │ runpy ./plan.py
SUCCESS │ runpy ./plan.py
START │ runsh nl limerick.txt > numbered.txt
SUCCESS │ runsh nl limerick.txt > numbered.txt
DIRECTOR │ Trying to delete 0 outdated output(s)
DIRECTOR │ Stopping workers
DIRECTOR │ See you!
As expected, StepUp does not wait for another step to create limerick.txt
because the file is static.
The file numbered.txt
will contain a copy of the limerick with line numbers.
Try the Following¶
-
Replace
gloom
byboom
inlimerick.txt
and runstepup boot -n 1
again. The line numbering is repeated, but the step./plan.py
is skipped as it did not change. -
Change the order of
static()
andrunsh()
inplan.py
and runstepup boot -n 1
again. This has no apparent effect, but the step is only sent to the worker process after the director is informed that the filelimerick.txt
is static. -
Comment out the
static()
function call and runstepup boot -n 1
again. StepUp will refuse to execute the line numbering step and will show a warning explaining why.