Skip to content

Workflow

Workflow

Workflow(name: str = 'workflow')

Define ordered stages without executing their tasks.

Parameters:

Name Type Description Default
name str

Nonempty workflow name used in the run manifest.

'workflow'
Example
from femora.jobs import Workflow, tasks
workflow = Workflow("analysis")
workflow.add("solve", tasks=[tasks.OpenSees("model", "model.tcl")])
workflow.outputs("solve/model/*.log")
Note

All tasks in one stage finish before the next stage starts. No automatic task retry or resume is provided. Use a fresh workspace for each run.

Methods:

Name Description
add

Append a named stage after all existing stages.

outputs

Select artifacts by glob, relative to the job workspace.

Attributes:

Name Type Description
stages tuple[_Stage, ...]

Ordered stage definitions as an immutable tuple; inspect, do not modify.

output_patterns tuple[str, ...]

Workspace-relative artifact glob patterns selected by outputs().

Attributes

stages property

stages: tuple[_Stage, ...]

Ordered stage definitions as an immutable tuple; inspect, do not modify.

output_patterns property

output_patterns: tuple[str, ...]

Workspace-relative artifact glob patterns selected by outputs().

Methods:

add

add(name: str, *, tasks: Sequence[Task], parallel: bool = False) -> Workflow

Append a named stage after all existing stages.

Parameters:

Name Type Description Default
name str

Unique directory-safe stage name.

required
tasks Sequence[Task]

Nonempty sequence of Python, Command, or OpenSees tasks.

required
parallel bool

Start all tasks together rather than sequentially.

False

Returns:

Name Type Description
workflow Workflow

This workflow, for chained calls.

Raises:

Type Description
ValueError

Stage/task names are invalid or duplicated, or tasks is empty.

TypeError

A task type or the parallel flag is invalid.

Note

A parallel stage must fit its combined core reservations inside the execution capacity. Dependencies belong in separate ordered stages.

outputs

outputs(*patterns: str) -> Workflow

Select artifacts by glob, relative to the job workspace.

Parameters:

Name Type Description Default
*patterns str

Relative glob patterns without parent traversal or backslashes.

()

Returns:

Name Type Description
workflow Workflow

This workflow, for chained calls.

Raises:

Type Description
ValueError

A pattern can escape the workspace or is empty.

Example
from femora.jobs import Workflow
workflow = Workflow().outputs("postprocess/**/*.csv", "**/*.log")