RunPolicy
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 RunPolicy(workers: int = 1, backend: str = 'serial', subject_timeout_sec: float | None = 900.0, subject_spawn_timeout_sec: float | None = 120.0, graceful_shutdown_sec: float = 15.0, on_subject_failure: str = 'continue', oom_backoff: bool = True, oom_reduce_workers_by: int = 1, cap_workers_to_gpu_pool: bool = False, resume: bool = True, checkpoint_dir: str | None = None, parallel_mode: str = 'persistent', auto_retry_rounds: int = 2, retry_failed_subjects: bool = False, force_rerun_subjects: ~typing.Tuple[str, ...] = <factory>, clear_checkpoint_on_success: bool = False, strict_checkpoint_hash: bool = False, persistent_worker_max_consecutive_failures: int = 1, persistent_worker_recycle_after_tasks: int = 0)[source]
Bases:
objectExecution policy for a study run.
- subject_timeout_sec
Wall-clock seconds allowed per subject before it is marked failed;
Nonedisables the per-subject timeout.- Type:
float | None
- subject_spawn_timeout_sec
Wall-clock seconds allowed for a worker process to start;
Nonedisables the spawn timeout.- Type:
float | None
- graceful_shutdown_sec
Seconds to wait after terminate() before kill() when a subject exceeds its timeout.
- Type:
- on_subject_failure
"continue"isolates a subject failure in its result slot;"fail_fast"aborts the run on the first failure.- Type:
- oom_backoff
Reduce workers after a fatal memory error so pending subjects can still run.
- Type:
- oom_reduce_workers_by
Workers subtracted per OOM backoff step; the effective worker count never drops below one.
- Type:
- cap_workers_to_gpu_pool
Clamp worker count to the usable GPU pool for steps whose components require a GPU.
- Type:
- checkpoint_dir
Directory for resumable subject results;
Nonelets the runner pick its default location.- Type:
str | None
- parallel_mode
"persistent"keeps one long-lived worker per slot;"isolated"spawns one child process per subject.- Type:
- auto_retry_rounds
Extra dispatch rounds for checkpoint-failed subjects within one run;
0disables.- Type:
- strict_checkpoint_hash
Raise instead of discarding checkpoints when the recorded run fingerprint is incompatible.
- Type:
- persistent_worker_max_consecutive_failures
Restart a persistent worker slot after this many consecutive fatal-class failures (
1matches v0.1; ignored in isolated mode).- Type:
- persistent_worker_recycle_after_tasks
Restart a persistent worker after this many successful tasks (
0disables; ignored in isolated mode).- Type:
- classmethod from_dict(payload: Mapping[str, Any]) RunPolicy[source]
Rebuild a run policy from its dict form, tolerating omissions.
Unknown keys are rejected so a misspelled field surfaces at load time instead of being silently dropped.
- Parameters:
payload – Mapping as produced by
to_dict(); every key is optional.- Returns:
The reconstructed policy.
- Raises:
HABITAPIError – On unknown keys or invalid values.
- __init__(workers: int = 1, backend: str = 'serial', subject_timeout_sec: float | None = 900.0, subject_spawn_timeout_sec: float | None = 120.0, graceful_shutdown_sec: float = 15.0, on_subject_failure: str = 'continue', oom_backoff: bool = True, oom_reduce_workers_by: int = 1, cap_workers_to_gpu_pool: bool = False, resume: bool = True, checkpoint_dir: str | None = None, parallel_mode: str = 'persistent', auto_retry_rounds: int = 2, retry_failed_subjects: bool = False, force_rerun_subjects: ~typing.Tuple[str, ...] = <factory>, clear_checkpoint_on_success: bool = False, strict_checkpoint_hash: bool = False, persistent_worker_max_consecutive_failures: int = 1, persistent_worker_recycle_after_tasks: int = 0) None