Executors¶
reflow.executors.Executor¶
reflow.executors.Executor(mode='', python='', config=None)
¶
Bases: ABC
Base class for workload-manager executors.
Subclasses must implement :meth:submit, :meth:cancel, and
:meth:job_state. The :attr:array_index_env_var class attribute
tells the worker which environment variable carries the array task
index at runtime.
Key normalisation
Users write scheduler-agnostic config (e.g. partition = "gpu"
or queue = "batch"). Each executor declares a
:attr:_KEY_ALIASES mapping that rewrites incoming keys to the
backend's native vocabulary before rendering CLI flags. This
means partition and queue are treated as synonyms — a
user never needs to know which scheduler is active.
Source code in src/reflow/executors/__init__.py
submit(resources, command)
abstractmethod
¶
cancel(job_id)
abstractmethod
¶
job_state(job_id)
abstractmethod
¶
dependency_options(job_ids)
¶
Return submit_options entries for depending on job_ids.
The dispatch loop calls this to build the dependency specification for the follow-up dispatch job. Each backend returns the correct key/value pair for its scheduler.
The default implementation produces Slurm-style
{"dependency": "afterany:ID1:ID2"}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_ids
|
list[str]
|
Job identifiers to depend on. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Entries to merge into submit_options. |
Source code in src/reflow/executors/__init__.py
reflow.executors.JobResources¶
reflow.executors.JobResources(job_name='', cpus=1, time_limit='00:30:00', mem='4G', array=None, output_path=None, error_path=None, submit_options=None, backend=None, extra=None)
dataclass
¶
Resource request for one task submission.
Source code in src/reflow/executors/__init__.py
extra
property
¶
Backward-compatible alias for scheduler-native submit options.
reflow.executors.slurm.SlurmExecutor¶
reflow.executors.slurm.SlurmExecutor(mode='sbatch', sbatch='sbatch', scancel='scancel', sacct='sacct', python='', config=None)
¶
Bases: Executor
Submit, cancel, and query Slurm jobs.
Source code in src/reflow/executors/slurm.py
from_environment(config=None)
classmethod
¶
Build from REFLOW_* environment variables and config.
Source code in src/reflow/executors/slurm.py
reflow.executors.pbs.PBSExecutor¶
reflow.executors.pbs.PBSExecutor(mode='qsub', qsub='qsub', qdel='qdel', qstat='qstat', array_flag=None, python='', config=None)
¶
Bases: Executor
Submit, cancel, and query PBS / Torque jobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
|
'qsub'
|
qsub
|
str
|
Path to the |
'qsub'
|
qdel
|
str
|
Path to the |
'qdel'
|
qstat
|
str
|
Path to the |
'qstat'
|
array_flag
|
str or None
|
|
None
|
python
|
str
|
Python interpreter for worker jobs. |
''
|
config
|
Config or None
|
User configuration. |
None
|
Source code in src/reflow/executors/pbs.py
from_environment(config=None)
classmethod
¶
Build from REFLOW_* environment variables and config.
Source code in src/reflow/executors/pbs.py
dependency_options(job_ids)
¶
reflow.executors.lsf.LSFExecutor¶
reflow.executors.lsf.LSFExecutor(mode='bsub', bsub='bsub', bkill='bkill', bjobs='bjobs', python='', config=None)
¶
Bases: Executor
Submit, cancel, and query LSF jobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
|
'bsub'
|
bsub
|
str
|
Path to the |
'bsub'
|
bkill
|
str
|
Path to the |
'bkill'
|
bjobs
|
str
|
Path to the |
'bjobs'
|
python
|
str
|
Python interpreter for worker jobs. |
''
|
config
|
Config or None
|
User configuration. |
None
|
Source code in src/reflow/executors/lsf.py
from_environment(config=None)
classmethod
¶
Build from REFLOW_* environment variables and config.
Source code in src/reflow/executors/lsf.py
dependency_options(job_ids)
¶
LSF dependency: -w "ended(ID1) && ended(ID2)".
reflow.executors.sge.SGEExecutor¶
reflow.executors.sge.SGEExecutor(mode='qsub', qsub='qsub', qdel='qdel', qstat='qstat', python='', config=None)
¶
Bases: Executor
Submit, cancel, and query SGE / UGE jobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
|
'qsub'
|
qsub
|
str
|
Path to the |
'qsub'
|
qdel
|
str
|
Path to the |
'qdel'
|
qstat
|
str
|
Path to the |
'qstat'
|
python
|
str
|
Python interpreter for worker jobs. |
''
|
config
|
Config or None
|
User configuration. |
None
|
Source code in src/reflow/executors/sge.py
from_environment(config=None)
classmethod
¶
Build from REFLOW_* environment variables and config.
Source code in src/reflow/executors/sge.py
reflow.executors.flux.FluxExecutor¶
reflow.executors.flux.FluxExecutor(mode='flux', flux='flux', python='', config=None)
¶
Bases: Executor
Submit, cancel, and query Flux jobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
|
'flux'
|
flux
|
str
|
Path to the |
'flux'
|
python
|
str
|
Python interpreter for worker jobs. |
''
|
config
|
Config or None
|
User configuration. |
None
|
Source code in src/reflow/executors/flux.py
from_environment(config=None)
classmethod
¶
Build from REFLOW_* environment variables and config.
Source code in src/reflow/executors/flux.py
dependency_options(job_ids)
¶
reflow.executors.local.LocalExecutor¶
reflow.executors.local.LocalExecutor(capture_output=False)
¶
Bases: Executor
Run tasks as local subprocesses (synchronous).
Source code in src/reflow/executors/local.py
reflow.executors.helpers¶
reflow.executors.helpers.default_executor(config)
¶
Return the default executor based on config mode.
Reads config.executor_mode (or the REFLOW_MODE env var)
to decide which backend to instantiate. Falls back to
:class:~reflow.executors.slurm.SlurmExecutor when no mode is
configured.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
User configuration. |
required |
Returns:
| Type | Description |
|---|---|
Executor
|
An executor instance for the configured backend. |
Source code in src/reflow/executors/helpers.py
reflow.executors.helpers.resolve_executor(executor)
¶
Resolve an executor shorthand string to an instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
executor
|
Executor, str, or None
|
Supported shorthands: |
required |