Core workflow objects¶
reflow.flow.Flow¶
reflow.flow.Flow(name)
¶
Reusable collection of task definitions.
Register tasks with job and array_job. A flow has
no execution machinery -- attach it to a reflow.Workflow
via Workflow.include.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Flow name. |
required |
Source code in src/reflow/flow.py
job(name=None, *, array=False, array_parallelism=None, cpus=1, time='00:30:00', mem='4G', after=None, submit_options=None, extra=None, version='1', cache=True, verify=None, backend=None, **scheduler_options)
¶
Register a task, singleton or array job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str or None
|
Task name. Defaults to the function name. |
None
|
array
|
bool
|
Set this to |
False
|
array_parallelism
|
int or None
|
Maximum concurrent array tasks. |
None
|
cpus
|
int
|
CPUs per task. |
1
|
time
|
str
|
Wall-clock time limit. |
'00:30:00'
|
mem
|
str
|
Memory request. |
'4G'
|
after
|
list[str] or None
|
Explicit ordering dependencies. |
None
|
submit_options
|
dict[str, Any] or None
|
Scheduler-native submit options, for example |
None
|
extra
|
dict[str, Any] or None
|
Backward-compatible alias for |
None
|
version
|
str
|
Cache version string. Bump to invalidate cached results when the task logic changes. |
'1'
|
cache
|
bool
|
Whether to cache results across runs. |
True
|
verify
|
callable or None
|
Custom output verification function. |
None
|
backend
|
str or None
|
Optional backend hint for future multi-backend execution. |
None
|
**scheduler_options
|
Any
|
Additional scheduler-native submit options. These are merged
with |
{}
|
Source code in src/reflow/flow.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
array_job(name=None, *, cpus=1, time='00:30:00', mem='4G', after=None, array_parallelism=None, submit_options=None, extra=None, version='1', cache=True, verify=None, backend=None, **scheduler_options)
¶
Register an array task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str or None
|
Task name. Defaults to the function name. |
None
|
cpus
|
int
|
CPUs per task. |
1
|
time
|
str
|
Wall-clock time limit. |
'00:30:00'
|
mem
|
str
|
Memory request. |
'4G'
|
after
|
list[str] or None
|
Additional explicit ordering dependencies. |
None
|
array_parallelism
|
int or None
|
Maximum concurrent array tasks. |
None
|
submit_options
|
dict[str, Any] or None
|
Scheduler-native submit options, for example |
None
|
extra
|
dict[str, Any] or None
|
Backward-compatible alias for |
None
|
version
|
str
|
Cache version string. |
'1'
|
cache
|
bool
|
Whether to cache results across runs. |
True
|
verify
|
callable or None
|
Custom output verification function. |
None
|
backend
|
str or None
|
Optional backend hint for future multi-backend execution. |
None
|
**scheduler_options
|
Any
|
Additional scheduler-native submit options. These are merged
with |
{}
|
Source code in src/reflow/flow.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
reflow.flow.JobConfig¶
reflow.flow.JobConfig(cpus=1, time='00:30:00', mem='4G', array=False, after=None, array_parallelism=None, submit_options=None, version='1', cache=True, backend=None, extra=None, **scheduler_options)
dataclass
¶
Resource and dependency configuration for a single task.
Source code in src/reflow/flow.py
extra
property
¶
Backward-compatible alias for scheduler-native submit options.
reflow.workflow.Workflow¶
reflow.workflow.Workflow(name, config=None)
¶
Bases: DispatchMixin, WorkerMixin, Flow
Runnable HPC workflow.
Extends Flow with execution: validation, CLI, submission,
dispatch, worker, cancel, retry, status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Workflow name. |
required |
config
|
Config or None
|
User configuration. Loaded from
|
None
|
Examples:
Direct task registration::
wf = Workflow("pipeline")
@wf.job()
def prepare(...) -> list[str]: ...
wf.cli()
Composing from flows::
conversion = Flow("conversion")
# ... tasks ...
wf = Workflow("experiment")
wf.include(conversion)
run = wf.submit(run_dir="/scratch/run1", start="2025-01-01")
run.status()
Source code in src/reflow/workflow/_core.py
include(flow, prefix=None)
¶
Include all tasks from a flow into this workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flow
|
Flow
|
Reusable flow. |
required |
prefix
|
str or None
|
Optional name prefix. Internal Result/after references within the flow are rewritten automatically. |
None
|
Source code in src/reflow/workflow/_core.py
validate()
¶
Run full graph validation.
Raises:
| Type | Description |
|---|---|
ValueError
|
Unresolved references or cycles. |
TypeError
|
Incompatible wired types. |
Source code in src/reflow/workflow/_core.py
cli(argv=None)
¶
Run the argparse CLI.
Source code in src/reflow/workflow/_core.py
submit(run_dir, *, store=None, executor=None, force=False, force_tasks=None, verify=False, **parameters)
¶
Create a new run and return an interactive Run handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_dir
|
str or Path
|
Shared working directory. |
required |
store
|
Store or None
|
Manifest store. Defaults to the shared
|
None
|
executor
|
Executor, str, or None
|
Workload-manager executor. |
None
|
force
|
bool
|
If |
False
|
force_tasks
|
list[str] or None
|
Task names to force-run even if cached. Other tasks may still use the cache. |
None
|
verify
|
bool
|
If |
False
|
**parameters
|
Any
|
Run parameters injected into task functions by name. |
{}
|
Returns:
| Type | Description |
|---|---|
Run
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If required parameters are missing. |
Source code in src/reflow/workflow/_core.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
submit_run(run_dir, parameters, store=None, executor=None)
¶
Lower-level submission used by the CLI. Returns run_id.
Source code in src/reflow/workflow/_core.py
retry_failed(run_id, store, run_dir, task_name=None, executor=None, verify=True)
¶
Retry failed/cancelled instances and re-dispatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
str
|
Run identifier. |
required |
store
|
Store
|
Manifest store for the run. |
required |
run_dir
|
Path
|
Working directory for the run. |
required |
task_name
|
str or None
|
Optional task name filter. |
None
|
executor
|
Executor or None
|
Explicit executor override. |
None
|
verify
|
bool
|
If |
True
|
Source code in src/reflow/workflow/_core.py
describe_typed()
¶
Return a typed workflow description.
This is the canonical manifest description used by external tooling and
future service integrations. describe converts it into a
JSON-safe dictionary.
Source code in src/reflow/workflow/_core.py
describe()
¶
Return a JSON-safe description of the workflow.
Includes task names, types, resource configs, dependencies, and CLI parameters -- everything a server would need to reconstruct the submit form and dispatch logic.
Source code in src/reflow/workflow/_core.py
reflow.run.Run¶
reflow.run.Run(workflow, run_id, run_dir, store)
¶
Bound handle to a submitted run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow
|
Workflow
|
The workflow that owns this run. |
required |
run_id
|
str
|
Unique run identifier. |
required |
run_dir
|
Path
|
Shared working directory. |
required |
store
|
Store
|
Manifest store. |
required |
Examples:
>>> run = workflow.submit(run_dir="/scratch/run1", start="2025-01-01")
>>> run.status()
>>> run.cancel()
>>> run.retry("convert")
Source code in src/reflow/run.py
status(task=None, as_dict=False)
¶
Show or return the current run status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str or None
|
Filter by task name. |
None
|
as_dict
|
bool
|
If |
False
|
Source code in src/reflow/run.py
cancel(task=None, executor=None)
¶
Cancel active task instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str or None
|
Cancel only this task. |
None
|
executor
|
Executor or None
|
Workload-manager executor. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of instances cancelled. |
Source code in src/reflow/run.py
retry(task=None, executor=None, verify=True)
¶
Retry failed or cancelled instances.
By default, cached upstream outputs are verified (file
existence for Path types, custom callables) before
resubmitting. Pass verify=False to skip verification
and trust the Merkle identity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str or None
|
Retry only this task. |
None
|
executor
|
Executor or None
|
Workload-manager executor. |
None
|
verify
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
int
|
Number of instances marked for retry. |