Spaces:
Running
Running
File size: 457 Bytes
877add7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | """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"))
|