"""Load training artifacts.""" from __future__ import annotations import json from pathlib import Path from typing import Any def read_jsonl(path: Path) -> list[dict[str, Any]]: rows = [] with path.open(encoding="utf-8") as fh: for line in fh: line = line.strip() if line: rows.append(json.loads(line)) return rows def write_json(path: Path, payload: Any) -> None: path.parent.mkdir(parents=True, exist_ok=True) path.write_text(json.dumps(payload, indent=2), encoding="utf-8")