| """Checkpoint utilities.""" | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| from typing import Any | |
| def save_checkpoint(path: Path, payload: dict[str, Any]) -> Path: | |
| path.parent.mkdir(parents=True, exist_ok=True) | |
| path.write_text(json.dumps(payload, ensure_ascii=True, indent=2), encoding="utf-8") | |
| return path | |
| def load_checkpoint(path: Path) -> dict[str, Any]: | |
| return json.loads(path.read_text(encoding="utf-8")) | |