loqs.tools.monitor.state¶
State aggregation for monitoring a running MultiProgramRunner dispatch.
Reads every worker's SWMR item ledger in one item_checkpoint_dir and
summarizes it as plain data. Nothing here renders or prints anything.
Classes¶
Attributes¶
| Name | Type | Value | Doc |
|---|---|---|---|
DEFAULT_STALE_AFTER |
120.0 |
||
RUN_PLAN_FILENAME |
'run_progress.json' |
Functions¶
compute_run_items ¶
compute_run_items(plan: RunPlan | None, ledgers: Sequence[SwmrLedgerSnapshot]) -> tuple[int, int] | None
Items done and total over all of a run's items, or None if unknown.
Items done before the run began count as done; a done mark outside
plan.pending_items is ignored, so no item counts twice.
compute_run_shots ¶
compute_run_shots(plan: RunPlan | None, ledgers: Sequence[SwmrLedgerSnapshot]) -> tuple[int, int] | None
Shots done and total over all of a run's items, or None if unknown.
Finished items are the union of the ledgers' done marks within
plan.pending_items; an unfinished current item contributes the
largest in-flight count across ledgers, capped at the per-item shots.
read_run_plan ¶
read_run_plan(directory: Path | str) -> RunPlan | None
Read the run plan, or None when missing, unreadable or malformed.
read_snapshot ¶
read_snapshot(directory: Path | str, *, stale_after: float = DEFAULT_STALE_AFTER, wall_clock: Callable[[], float] = time.time) -> MonitorSnapshot
Poll directory once with a fresh MonitorTracker.
remove_run_plan ¶
remove_run_plan(directory: Path | str) -> None
Delete the run plan file, ignoring a missing file or any OSError.
write_run_plan ¶
write_run_plan(directory: Path | str, plan: RunPlan) -> None
Write plan to directory; on OSError warn and remove the file.
Never raises OSError: the plan is display only, so a failed write
must not fail the run.