File size: 2,633 Bytes
af5b4af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""Build submission.json for the OpenEnv Arena.

Reads the schema from a running server, so the submitted schema is exactly what
GET /schema returns. Tasks come from --tasks (comma list) or a file with one id per line.

Usage:
  python tools/make_submission.py --url http://localhost:18001 --image ghcr.io/syndicate604/science-desk@sha256:... \
      --tasks-file runs/selected.txt --id science-desk-v5 --out submission.json
"""

import argparse
import json
import sys

import httpx

sys.path.insert(0, ".")
from terminal_desk.families import parse_task_id  # noqa: E402

# Copied verbatim from the arena operator's own smoke submission (benchflow/openenv-smoke-fix-git),
# so training runs under the budgets the private tasks are believed to use.
LIMITS = {
    "split": "train",
    "cleanup_grace_s": 30,
    "completion_tokens": 4096,
    "context_tokens": 8192,
    "cpu_floor_vcpus": 1.0,
    "memory_gib": 2.0,
    "reset_wall_s": 300,
    "rollout_wall_s": 902,
    "tool_calls_inflight": 1,
    "tool_calls_per_minute": 60,
    "tool_calls_total": 32,
    "tool_rate_burst": 4,
    "tool_wall_s": 110,
    "verifier_wall_s": 600,
    "workspace_gib": 10,
}


def main() -> None:
    p = argparse.ArgumentParser()
    p.add_argument("--url", required=True)
    p.add_argument("--image", required=True)
    p.add_argument("--id", required=True)
    p.add_argument("--tasks", default="")
    p.add_argument("--tasks-file", default="")
    p.add_argument("--dataset", default="Syndicate604/science-desk")
    p.add_argument("--name", default="Science Desk")
    p.add_argument("--out", required=True)
    a = p.parse_args()
    ids = [t for t in a.tasks.split(",") if t] if a.tasks else [
        ln.strip() for ln in open(a.tasks_file) if ln.strip() and not ln.startswith("#")
    ]
    for t in ids:
        parse_task_id(t)
    if not 1 <= len(ids) <= 50:
        raise SystemExit(f"need 1-50 tasks, got {len(ids)}")
    schema = httpx.get(f"{a.url}/schema", timeout=10).json()
    sub = {
        "submission_id": a.id,
        "name": a.name,
        "image": a.image,
        "schema": {"action": schema["action"], "observation": schema["observation"]},
        "tasks": [{"task_id": t, **LIMITS} for t in ids],
        "example_actions": [{"action_type": "exec", "command": "ls -la"}, {"action_type": "evaluate"}],
        "finish_action": {"action_type": "evaluate"},
        "dataset": a.dataset,
        "source": f"https://huggingface.co/datasets/{a.dataset}",
    }
    json.dump(sub, open(a.out, "w"), indent=2)
    print(f"wrote {a.out}: {len(ids)} tasks, image {a.image}")


if __name__ == "__main__":
    main()