clsa-code / experiments /build_figures.py
fahadhafeezofficial's picture
Upload folder using huggingface_hub
fd5366a verified
Raw History Blame Contribute Delete
1.08 kB
# 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()