#!/usr/bin/env python3 """Freezes the memo. Renders thesis/THESIS.tmpl.md and thesis/README.tmpl.md from the current metrics and keeps those metrics. The dashboard keeps moving, the memo does not. Every number in THESIS.md and README.md comes from this render, so a hand-edited number fails pipeline/verify_claims.py, which re-renders from the frozen metrics and compares bytes. """ import json, pathlib, shutil, sys ROOT = pathlib.Path(__file__).resolve().parent.parent sys.path.insert(0, str(ROOT / "pipeline")) from build import derived, render # noqa: E402 def main(): shutil.copy(ROOT / "docs" / "data" / "metrics.json", ROOT / "thesis" / "metrics_frozen.json") shutil.copy(ROOT / "docs" / "data" / "model.json", ROOT / "thesis" / "model_frozen.json") shutil.copy(ROOT / "docs" / "data" / "grades.json", ROOT / "thesis" / "grades_frozen.json") metrics = derived(json.loads((ROOT / "thesis" / "metrics_frozen.json").read_text())) model = json.loads((ROOT / "thesis" / "model_frozen.json").read_text()) grades = json.loads((ROOT / "thesis" / "grades_frozen.json").read_text()) for src, dst in (("thesis/THESIS.tmpl.md", "THESIS.md"), ("thesis/README.tmpl.md", "README.md")): path = ROOT / src if path.exists(): (ROOT / dst).write_text(render(path.read_text(), metrics, model, grades, escape=False)) print("rendered", dst) if __name__ == "__main__": sys.exit(main())