Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
52 lines
2.4 KiB
Python
52 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate the holder job scripts of the matrix (one job per repetition, so the other agents' jobs can run between them).
|
|
|
|
gen_jobs.py --plan "fixbug-ledger:3,ttt:3,feature-query:3,debuglog-sched:2,refactor-shop:2,crm:1" --out DIR [--order "ttt,crm,fixbug-ledger,..."]
|
|
|
|
--plan is task:n (n repeats). Repetition k contains every task with n >= k. Variant order per repetition (the lossy/lossless pair of an engine stays adjacent):
|
|
rep 1 V1 V2 V3 V4, rep 2 V2 V1 V4 V3, rep 3 V3 V4 V1 V2, rep 4 V4 V3 V2 V1 (then repeating). The task order inside a block is the --order list rotated by (k - 1).
|
|
Cells that already exist (the pilot's fixbug-ledger r1 and r2) are skipped by block.py.
|
|
"""
|
|
import argparse
|
|
import os
|
|
|
|
ROWS = [["V1", "V2", "V3", "V4"], ["V2", "V1", "V4", "V3"], ["V3", "V4", "V1", "V2"], ["V4", "V3", "V2", "V1"]]
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--plan", required=True)
|
|
ap.add_argument("--out", required=True)
|
|
ap.add_argument("--order", default="ttt,fixbug-ledger,feature-query,debuglog-sched,refactor-shop,crm")
|
|
ap.add_argument("--prefix", default="cld-matrix")
|
|
a = ap.parse_args()
|
|
plan = {}
|
|
for tok in a.plan.split(","):
|
|
t, n = tok.split(":")
|
|
plan[t] = int(n)
|
|
order = [t for t in a.order.split(",") if t in plan]
|
|
assert set(order) == set(plan), "every planned task must appear in --order"
|
|
os.makedirs(a.out, exist_ok=True)
|
|
for k in range(1, max(plan.values()) + 1):
|
|
tasks = [t for t in order if plan[t] >= k]
|
|
shift = (k - 1) % len(tasks) if tasks else 0
|
|
tasks = tasks[shift:] + tasks[:shift]
|
|
cells = " ".join("%s:%d" % (t, k) for t in tasks)
|
|
name = "%s-r%d" % (a.prefix, k)
|
|
body = ["#!/usr/bin/env bash",
|
|
"# Generated by delta/gen_jobs.py: repetition %d of the matrix. Stub in ~/work/gpu-runs/holder2/jobs: exec bash <this file>." % k,
|
|
"set -uo pipefail",
|
|
"B=/data/leleka-e2e/codex-lossy-delta/delta/block.sh",
|
|
"for V in %s; do" % " ".join(ROWS[(k - 1) % 4]),
|
|
" bash \"$B\" \"$V\" r%d \"%s\"" % (k, cells),
|
|
" echo \"=== block $V done rc=$? $(date -u +%FT%TZ)\"",
|
|
" sleep 20",
|
|
"done", ""]
|
|
with open(os.path.join(a.out, name + ".sh"), "w", newline="\n") as f:
|
|
f.write("\n".join(body))
|
|
print(name, cells)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|