Download REPRODUCE.py from PureOne/Infinite-Players: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/datasets/PureOne/Infinite-Players/resolve/main/REPRODUCE.py
- Command line
-
hf download hf://datasets/PureOne/Infinite-Players/REPRODUCE.py
-
curl -L -o REPRODUCE.py https://huggingface.co/datasets/PureOne/Infinite-Players/resolve/main/REPRODUCE.py
3.16 kB
| """Fresh-output reproduction and byte comparison for deterministic research assets.""" | |
| from __future__ import annotations | |
| import argparse,hashlib,json,os,subprocess,sys | |
| from pathlib import Path | |
| def main(): | |
| p=argparse.ArgumentParser();p.add_argument('--output',type=Path,required=True);p.add_argument('--legacy',action='store_true',help='Also rerun the untouched original v2 ZIP');a=p.parse_args() | |
| root=Path(__file__).resolve().parent;out=a.output.resolve() | |
| if a.legacy and not (root/'legacy/Infinite_Players_v2_original.zip').is_file(): | |
| raise SystemExit('The legacy v2 ZIP is excluded from this Hugging Face edition. Restore it at legacy/Infinite_Players_v2_original.zip from the original handoff, or omit --legacy. No output was created.') | |
| if out.exists():raise SystemExit('Output already exists; choose a new directory. Reference assets are never overwritten.') | |
| out.mkdir(parents=True);(out/'results').mkdir();(out/'logs').mkdir() | |
| env={**os.environ,'PYTHONPATH':str(root/'src'),'OPENBLAS_NUM_THREADS':'1','OMP_NUM_THREADS':'1','MKL_NUM_THREADS':'1','MPLCONFIGDIR':str(out/'.mplcache')} | |
| commands=[('tests',[sys.executable,'-m','unittest','discover','-s',str(root/'tests'),'-v']),('studies',[sys.executable,str(root/'experiments/run_all.py'),'--output',str(out/'results')]),('exact_audits',[sys.executable,str(root/'experiments/exact_audits.py'),'--output',str(out/'results/exact_audits.json')]),('figures',[sys.executable,str(root/'experiments/make_figures.py'),'--results',str(out/'results'),'--output',str(out/'figures')]),('demo',[sys.executable,'-m','infinite_players.demo','--output',str(out/'examples/demo')])] | |
| for name,args in commands: | |
| print('RUN',name,flush=True) | |
| result=subprocess.run(args,cwd=root,env=env,capture_output=True,text=True) | |
| (out/'logs'/f'{name}.txt').write_text(result.stdout+'\n'+result.stderr,encoding='utf-8') | |
| if result.returncode:print(result.stdout+result.stderr);raise SystemExit(result.returncode) | |
| expected=json.loads((root/'REFERENCE_HASHES.json').read_text()) | |
| comparisons=[] | |
| for relative,digest in expected.items(): | |
| file=out/relative;actual=hashlib.sha256(file.read_bytes()).hexdigest() if file.exists() else None | |
| comparisons.append({'file':relative,'expected':digest,'actual':actual,'match':actual==digest}) | |
| report={'deterministic_files':len(comparisons),'matched':sum(x['match'] for x in comparisons),'tests':'50 v3 unit tests executed','comparisons':comparisons,'scope':'same-environment source-only reproduction; not external replication'} | |
| (out/'REPRODUCTION_REPORT.json').write_text(json.dumps(report,indent=2,sort_keys=True)+'\n',encoding='utf-8') | |
| if a.legacy: | |
| subprocess.run([sys.executable,str(root/'experiments/reproduce_legacy.py'),'--output',str(out/'legacy_check')],cwd=root,env=env,check=True) | |
| print(f"Matched {report['matched']}/{report['deterministic_files']} deterministic files.") | |
| if report['matched']!=report['deterministic_files']: | |
| raise SystemExit('Byte mismatch: inspect the report and numerical environment; do not silently accept it.') | |
| if __name__=='__main__':main() | |