data-gen-bpu/scripts/queue_smoke.py

41 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""New fixture only; no production DB or compilation."""
import json
import os
import subprocess
import time
from pathlib import Path
bench = Path(__file__).resolve().parents[1]
root = (bench / "state/guard-smoke" / ("queue-" + str(time.time_ns()))).resolve()
os.environ["BENCH_STATE_DIR"] = str(root / "db")
from harness import paths
from harness.stageworker import Worker
jd = root / 'runs/rSmoke/cls--smoke--nash-e--ptq--int8'
rd = (jd / 'rollouts/01').resolve()
for d in ['workspace', 'handles', 'agent', 'stages']:
(rd / d).mkdir(parents=True)
job = json.loads((bench / 'runs/r20260915-03/cls--resnet18--nash-e--ptq--int8/job.json').read_text())
job.update(run_id='rSmoke', job_id=jd.name)
(jd / 'job.json').write_text(json.dumps(job))
other = jd.parent / 'cls--resnet18--nash-m--ptq--int8/oracle'
other.mkdir(parents=True)
(other / 'result.json').write_text('{"secret":"OTHER-JOB-DECOY"}')
(jd/'rollouts/00').mkdir()
(jd/'rollouts/00/claim.json').write_text('{"secret":"SIBLING-DECOY"}')
(rd / 'rollout.json').write_text('{}')
(jd / 'oracle').mkdir()
(jd / 'oracle/result.json').write_text('{"secret": "hidden"}')
print('fixture:', rd, flush=True)
jail = [str(paths.BENCH_ROOT / 'scripts/agent_jail.sh'), str(rd), 'e2e', '--']
subprocess.run([str(paths.BENCH_ROOT/'scripts/jail_probe.sh'), str(rd)], check=True)
with Worker(rd):
cmd = f'{paths.BENCH_ROOT}/bin/bench stage run calibrate'
p = subprocess.run(jail + ['bash','-c', cmd], capture_output=True, text=True, check=True)
hid = p.stdout.splitlines()[0]
p = subprocess.run(jail + [str(paths.BENCH_ROOT/'bin/bench'), 'stage', 'wait', hid, '--poll', '1'],
capture_output=True, text=True, timeout=60, check=True)
print(p.stdout)
status = json.loads((rd/'handles'/hid/'status.json').read_text())
assert status['state'] == 'DONE' and status['result'] == 'OK'
print('QUEUE RESULT: OK (real calibrate; isolated fixture DB)', flush=True)