"""Provision only a new worktree and independent benchmark environment.""" import json import os from pathlib import Path import subprocess import sys from datetime import datetime, timezone ROOT=Path('/data/digital-drosophila') WORK=Path('/home/qishizhe/digital-drosophila-v100-acceleration') OUT=Path('/home/qishizhe/phase4ar-v100-acceleration-20261001') BASE='09187e4d4d67badf1b418c5f211258ca5d8fb328' def run(argv, log): with (OUT/(log+'.stdout.log')).open('x') as out, (OUT/(log+'.stderr.log')).open('x') as err: r=subprocess.run(argv,stdout=out,stderr=err,env={**os.environ,'PYTHONDONTWRITEBYTECODE':'1'}) print(json.dumps({'step':log,'exit_code':r.returncode}),flush=True) if r.returncode:raise RuntimeError('Environment preparation failed: '+log) assert not WORK.exists() and not OUT.exists(), 'Provisioning targets must be new' assert subprocess.check_output(['git','-C',str(ROOT),'rev-parse','HEAD'],text=True).strip()==BASE assert subprocess.check_output(['git','-C',str(ROOT),'status','--porcelain'],text=True)=='' OUT.mkdir() with (OUT/'environment-authority.json').open('x') as f: json.dump(dict(scope='independent engineering replay only',base_commit=BASE, created_utc=datetime.now(timezone.utc).isoformat(),original_science_environment_modified=False, original_experiment_resumed=False),f,indent=2) run(['git','-C',str(ROOT),'worktree','add','-b','codex/v100-conditioning-acceleration',str(WORK),BASE],'create-worktree') run([sys.executable,'-m','venv',str(OUT/'.venv')],'create-venv') run([str(OUT/'.venv/bin/python'),'-B','-m','pip','install','--disable-pip-version-check', '--report',str(OUT/'pip-install-report.json'),'numpy==2.2.6','cupy-cuda12x==13.6.0'],'install-candidate') run([str(OUT/'.venv/bin/python'),'-B','-m','pip','freeze'],'candidate-freeze') print(json.dumps({'worktree':str(WORK),'benchmark_root':str(OUT),'environment_ready':True}),flush=True)