sahiljagtap's picture
Drums launch benchmarks reproduction + paired Drums/Prime/E2B re-run (scrubbed)
4ef198a
Raw History Blame Contribute Delete
2.54 kB
"""suite.py OUT TASK_ID...: OSWorld tasks on the installed release, one at a time. Per task: create(task) (its setup,
provisioning steps included), wait_valid, verify(strict=False) on the start state; fork(K) children, each
verify(strict=False) and compare with the parent's score; one child reset and verified again. A task passes when the
setup succeeds, every episode is valid, the checker scores every one (no checker error) and children equal the parent.
Unsupported tasks (TaskUnsupported) are recorded as such. K from env SUITE_K (default 2)."""
import json
import os
import sys
import time
import drums
OUT = sys.argv[1]
K = int(os.environ.get("SUITE_K", "2"))
os.makedirs(OUT, exist_ok=True)
log = open(os.path.join(OUT, "suite.jsonl"), "a")
def rec(**kw):
kw["t"] = round(time.time(), 3)
log.write(json.dumps(kw, default=str) + "\n")
log.flush()
print(json.dumps(kw, default=str)[:500], flush=True)
def rv(r):
return {"score": r.score, "valid": r.valid, "verdict": r.verdict, "bad_gates": r.bad_gates, "reasons": r.invalid_reasons,
"checker_error": r.checker_error}
with drums.connect() as c:
for tid in sys.argv[2:]:
t0 = time.monotonic()
row = {"task": tid}
try:
with c.create(task=tid) as p:
p.wait_valid()
row["create_s"] = round(time.monotonic() - t0, 3)
row["task_setup_s"] = p.record.get("timings", {}).get("task_setup")
pr = p.verify(strict=False)
row["parent"] = rv(pr)
with p.fork(K, keep_state=False) as kids:
row["children"] = []
for k in kids:
k.wait_valid()
row["children"].append(dict(env=k.id, **rv(k.verify(strict=False))))
k = kids[0]
k.reset()
k.wait_valid()
row["reset_child"] = dict(env=k.id, **rv(k.verify(strict=False)))
eps = [row["parent"]] + row["children"] + [row["reset_child"]]
row["pass"] = all(e["valid"] and e["score"] is not None for e in eps) and all(e["score"] == row["parent"]["score"] for e in eps)
except drums.TaskUnsupported as e:
row.update(unsupported=True, reason=e.reason, **{"pass": None})
except Exception as e: # noqa: BLE001
row.update(error=f"{type(e).__name__}: {str(e)[:600]}", **{"pass": False})
row["seconds"] = round(time.monotonic() - t0, 3)
rec(**row)