#!/usr/bin/env python3 """Reproduce in a NEW workspace without overwriting the delivered evidence.""" from __future__ import annotations import argparse, os, shutil, subprocess, sys from pathlib import Path def main(): parser=argparse.ArgumentParser() parser.add_argument('--output',required=True,type=Path,help='New, nonexistent directory') args=parser.parse_args() source=Path(__file__).resolve().parents[1] target=args.output.expanduser().resolve() if target.exists(): raise SystemExit(f'Refusing to overwrite an existing path: {target}') (target/'code').mkdir(parents=True) for name in ('benchmark.py','analyze.py','diagnostic_unnormalized.py'): shutil.copy2(source/'code'/name,target/'code'/name) shutil.copy2(source/'protocol.json',target/'protocol.json') env=os.environ.copy() for key in ('OPENBLAS_NUM_THREADS','OMP_NUM_THREADS','MKL_NUM_THREADS','NUMBA_NUM_THREADS'): env[key]='1' for script in ('benchmark.py','analyze.py','diagnostic_unnormalized.py'): subprocess.run([sys.executable,str(target/'code'/script)],check=True,env=env) print(f'Reproduced results: {target}') if __name__=='__main__':main()