"""Run all seven checks and save fresh logs. Execute without Python's -O flag.""" from concurrent.futures import ThreadPoolExecutor from pathlib import Path import json import platform import subprocess import sys import time ROOT = Path(__file__).resolve().parent SCRIPTS = ("latticecheck.py", "momentcheck.py", "walshcheck.py", "irate.py", "fourcheck.py", "ptwocheck.py", "pthreecheck.py") def run(script): start = time.monotonic() with (ROOT / "logs" / Path(script).with_suffix(".log")).open("w") as log: result = subprocess.run([sys.executable, "-u", script], cwd=ROOT, stdout=log, stderr=subprocess.STDOUT) row = {"script": script, "returncode": result.returncode, "seconds": round(time.monotonic() - start, 3)} print(f"{script}: {'PASS' if result.returncode == 0 else 'FAIL'} " f"({row['seconds']} s)", flush=True) return row if __name__ == "__main__": if not __debug__: raise SystemExit("Assertions are required; run without -O.") (ROOT / "logs").mkdir(exist_ok=True) with ThreadPoolExecutor(max_workers=2) as pool: results = list(pool.map(run, SCRIPTS)) import numpy import scipy summary = {"python": platform.python_version(), "numpy": numpy.__version__, "scipy": scipy.__version__, "checks": results} (ROOT / "logs" / "run-summary.json").write_text(json.dumps(summary, indent=2)+"\n") sys.exit(any(row["returncode"] for row in results))