27 lines
2.6 KiB
Python
27 lines
2.6 KiB
Python
from pathlib import Path
|
|
import tempfile,json,subprocess,os,sys,zipfile,numpy as np
|
|
repo=Path('/home/frank14f/optane/MeltMind');base=Path(tempfile.mkdtemp(prefix='meltmind-calib-runner-'));records=[]
|
|
for fail in [False,True]:
|
|
root=base/('failure' if fail else 'success');(root/'custodian').mkdir(parents=True);cache=root/'cache';cache.mkdir();archive=root/'empty.zip'
|
|
with zipfile.ZipFile(archive,'w'):pass
|
|
st=archive.stat();ver=root/'archive.json';ver.write_text(json.dumps({'bytes':st.st_size,'mtime_ns':st.st_mtime_ns,'inode':st.st_ino}))
|
|
jobs=[]
|
|
for i in range(2):
|
|
case=f'{i+1:08d}_fixture_step_000'
|
|
if not fail:np.savez_compressed(cache/(case+'.npz'),points=np.array([[0.,0,0],[3.,0,0],[0,2.,0],[0,0,1.]]),boundary=np.array([[0,1,2],[0,1,3],[0,2,3],[1,2,3]]),center=np.array([.75,.5,.25]),rg=np.array(1.1))
|
|
jobs.append({'cases':[case],'pairs':[{'id':f'p{i}','a':case,'kind':'rigid','rotation':np.eye(3).tolist(),'unit_translation':[1,2,3],'source_sampling_prefix':i+1,'target_sampling_prefix':1000000+i}]})
|
|
(root/'custodian/plan.json').write_text(json.dumps({'jobs':jobs}))
|
|
contract={'code_sha256':{},'input_sha256':{},'archive':str(archive),'archive_verification':str(ver),'existing_registration_cache':str(cache),'per_pair_wall_seconds':60,'workers':2,'per_worker_rss_bytes':1342177280,'aggregate_rss_bytes':3*1024**3,'disk_bytes':1024**3,'wall_seconds':90,'worker_cpu_budget_seconds':180}
|
|
(root/'contract.json').write_text(json.dumps(contract))
|
|
env=dict(os.environ,MELTMIND_G1_CALIBRATION_ROOT=str(root),OMP_NUM_THREADS='1',OPENBLAS_NUM_THREADS='1',MKL_NUM_THREADS='1',CUDA_VISIBLE_DEVICES='')
|
|
p=subprocess.run([sys.executable,'tools/run_g1_copy_calibration.py'],cwd=repo,env=env,capture_output=True,text=True,timeout=110)
|
|
output=json.loads((root/('batch-incomplete.json' if fail else 'batch-complete.json')).read_text())
|
|
assert (p.returncode!=0)==fail and len(output['jobs'])==2
|
|
assert output['failed_jobs']==(2 if fail else 0)
|
|
assert len(list((root/'jobs').glob('*/worker.receipt.json')))==2
|
|
assert all(j['worker']['returncode'] is not None for j in output['jobs'])
|
|
records.append({'case':'intentional_missing_geometry' if fail else 'two_parallel_synthetic_jobs','pass':True,'returncode':p.returncode,'worker_cpu_seconds':output['worker_cpu_seconds'],'failed_jobs':output['failed_jobs'],'wall_seconds':output['wall_seconds']})
|
|
print(records[-1],flush=True)
|
|
(repo/'artifacts/s2-g1-copy-calibration-tests-2026-11-14').mkdir(exist_ok=True)
|
|
(repo/'artifacts/s2-g1-copy-calibration-tests-2026-11-14/runner-tests.json').write_text(json.dumps({'tests':records,'fixture_root':str(base),'no_real_geometry_read':True},indent=2)+'\n')
|