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: object

Run subject-level work one item at a time in the current process.

This is the reference ExecutionBackend implementation: correct by construction, trivially debuggable, and the default behind Cohort.map(op).

Parameters:
  • on_subject_failure – "continue" captures a subject’s exception in its SubjectResult and 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 op to 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 resume is set; outcomes are written regardless.

  • progress – Optional callback receiving (completed, total).

Yields:

One SubjectResult per item, in input order.

Raises:

BaseException – The first subject failure, when on_subject_failure is "fail_fast".

Examples using habit.execution.SerialBackend

Preprocessing voxel texture before clustering

Preprocessing voxel texture before clustering

Running the same study on each backend

Running the same study on each backend