File size: 1,077 Bytes
fd5366a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # Copyright (c) 2026 CLSA contributors
# SPDX-License-Identifier: MIT
"""Regenerate every figure from results/. A missing result skips its figure."""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
FIGURES = Path(__file__).resolve().parents[1] / "figures"
SCRIPTS = sorted(FIGURES.glob("f*.py"))
def main() -> None:
failed = []
for script in SCRIPTS:
out = subprocess.run(
[sys.executable, script.name], cwd=str(FIGURES), capture_output=True, text=True
)
status = "ok" if out.returncode == 0 else "skipped/failed"
print(f"[{status}] {script.name}")
if out.returncode != 0:
failed.append((script.name, (out.stderr or "").strip().splitlines()[-1:]))
if failed:
print("\nFigures not produced (with reason):")
for name, err in failed:
print(f" {name}: {err}")
tables = FIGURES / "tables.py"
if tables.exists():
subprocess.run([sys.executable, "tables.py"], cwd=str(FIGURES))
if __name__ == "__main__":
main()
|