SerialBackend
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- class SerialBackend(on_subject_failure: str = 'continue', *, resume: bool = True, retry_failed_subjects: bool = False, force_rerun_subjects: Tuple[str, ...] = (), clear_checkpoint_on_success: bool = False)[source]
Bases:
objectRun subject-level work one item at a time in the current process.
This is the reference
ExecutionBackendimplementation: correct by construction, trivially debuggable, and the default behindCohort.map(op).- Parameters:
on_subject_failure –
"continue"captures a subject’s exception in itsSubjectResultand proceeds;"fail_fast"re-raises the first failure immediately.resume – Reuse checkpointed successes and honour recorded failures. Writes to the store happen regardless, matching
ProcessPoolBackend.retry_failed_subjects – Re-run subjects whose checkpoint records a failure instead of skipping them.
force_rerun_subjects – Subject ids reprocessed even when a checkpoint success exists.
clear_checkpoint_on_success – Clear the checkpoint store after a run with zero failures.
- __init__(on_subject_failure: str = 'continue', *, resume: bool = True, retry_failed_subjects: bool = False, force_rerun_subjects: Tuple[str, ...] = (), clear_checkpoint_on_success: bool = False) None[source]
- map(op: SubjectOperator[TIn, TOut], items: Iterable[TIn], *, checkpoint: CheckpointStore | None = None, progress: Callable[[int, int], None] | None = None) Iterator[SubjectResult[TOut]][source]
Apply
opto each item in iteration order.- Parameters:
op – The subject-level operation to run.
items – Subject-scoped inputs.
checkpoint – Optional store used to skip already-computed subjects and to persist new results as they complete. Cached successes and recorded failures are honoured only when this backend’s
resumeis set; outcomes are written regardless.progress – Optional callback receiving
(completed, total).
- Yields:
One
SubjectResultper item, in input order.- Raises:
BaseException – The first subject failure, when
on_subject_failureis"fail_fast".