data-gen-bpu/scripts/queue_smoke.py

33 lines
1.4 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
from harness import paths
from harness.stageworker import Worker
root = paths.STATE / 'guard-smoke' / ('queue-' + str(time.time_ns()))
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)
(jd / 'job.json').write_text('{}')
(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, test_noop=True):
cmd = f'{paths.BENCH_ROOT}/bin/bench stage run noop'
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', flush=True)