run workflows
Execute ordered workflow stages locally or inside an existing allocation.
Use execute() after defining a Workflow. It checks capacity, starts task processes, and writes manifest.json in the workspace. A Python task returns its callback value; command and solver tasks return ProcessResult objects containing their log paths. Selected output files appear separately in RunResult.artifacts.
from femora.jobs import execute, WorkflowExecutionError
def run_locally(workflow):
try:
run = execute(workflow, workspace="new-run", cores=1)
except WorkflowExecutionError as error:
print("Inspect the partial manifest:", error.run.manifest)
raise
return run
Call the wrapper from a main-guarded Python script. The runner does not submit a scheduler job, install a solver, or automatically retry failed tasks. Use a fresh workspace to avoid confusing old files with new results.
Functions:
execute
execute(workflow: Workflow, *, workspace: str | Path, inputs: Mapping[str, Any] | None = None, cores: int | None = None, backend: TACC | None = None) -> RunResult
Run a workflow using separate processes for its tasks.
A parallel stage starts all of its tasks concurrently. It is rejected if
the sum of task core reservations exceeds cores. Local OpenSees tasks
are serial. Pass backend=jobs.backends.TACC() inside a Slurm allocation
to launch MPI tasks with ibrun. This does not submit a scheduler job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow
|
Workflow
|
Ordered stages to execute. |
required |
workspace
|
str | Path
|
Run directory; prefer a new directory per run. |
required |
inputs
|
Mapping[str, Any] | None
|
Shared inputs supplied to Python task contexts. |
None
|
cores
|
int | None
|
Capacity for task reservations; defaults to local CPU count or the current allocation capacity. |
None
|
backend
|
TACC | None
|
Allocation execution policy, or None for local execution. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
run |
RunResult
|
Task values, selected artifacts, workspace, and manifest. |
Raises:
| Type | Description |
|---|---|
TypeError
|
Workflow or backend has an unsupported type. |
ValueError
|
Capacity or allocation configuration is invalid. |
WorkflowExecutionError
|
A stage cannot fit the capacity or a task fails. |
Note
Task failures stop later stages. The exception's run attribute retains the partial manifest. No remote submission or automatic retry occurs. Python callbacks need importable functions and a main-guarded entry point.