Preserve phase timings across resume runs
This commit is contained in:
@@ -33,6 +33,22 @@ def _new_phase_timings() -> dict[str, object]:
|
||||
}
|
||||
|
||||
|
||||
def _load_phase_timings(path: Path, *, resume: bool) -> dict[str, object]:
|
||||
if not resume or not path.exists():
|
||||
return _new_phase_timings()
|
||||
try:
|
||||
phase_timings = json.loads(path.read_text(encoding="utf-8"))
|
||||
except (OSError, json.JSONDecodeError):
|
||||
return _new_phase_timings()
|
||||
if not isinstance(phase_timings, dict):
|
||||
return _new_phase_timings()
|
||||
if phase_timings.get("schema_version") != "phase-timings-v1":
|
||||
return _new_phase_timings()
|
||||
if not isinstance(phase_timings.get("phases"), dict):
|
||||
phase_timings["phases"] = {}
|
||||
return phase_timings
|
||||
|
||||
|
||||
def _write_phase_timings(
|
||||
output_dir: Path,
|
||||
phase_timings: dict[str, object],
|
||||
@@ -104,10 +120,13 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
|
||||
output_dir = Path(config["output"]["dir"])
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
phase_timings = _new_phase_timings()
|
||||
|
||||
video_manifest_path = output_dir / "video_manifest.jsonl"
|
||||
resume_enabled = bool(config.get("output", {}).get("resume", False))
|
||||
phase_timings = _load_phase_timings(
|
||||
output_dir / "phase_timings.json",
|
||||
resume=resume_enabled,
|
||||
)
|
||||
records = _load_resume_records(
|
||||
video_manifest_path,
|
||||
resume=resume_enabled,
|
||||
|
||||
Reference in New Issue
Block a user