Download make_shards.py from crmsndu/evolving-infra-traces: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/datasets/crmsndu/evolving-infra-traces/resolve/main/make_shards.py
- Command line
-
hf download hf://datasets/crmsndu/evolving-infra-traces/make_shards.py
-
curl -L -o make_shards.py https://huggingface.co/datasets/crmsndu/evolving-infra-traces/resolve/main/make_shards.py
1.43 kB
| """Split a workload into the per-process files the paper's runs replayed. | |
| python make_shards.py putnam/decode-heavy-100.stationary.jsonl putnam/shards.json out/putnam | |
| python make_shards.py osworld/osworld2-kimi-formal.jsonl osworld/shards.json out/osworld \ | |
| --image-root "$PWD/osworld/screenshots" | |
| Each output shard-<i>.jsonl goes to one replay client process (workload_path=...). | |
| """ | |
| import argparse | |
| import json | |
| import pathlib | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("workload") | |
| parser.add_argument("shards") | |
| parser.add_argument("out") | |
| parser.add_argument("--image-root", help="where the screenshots were downloaded (OSWorld)") | |
| args = parser.parse_args() | |
| rows = pathlib.Path(args.workload).read_text().splitlines() | |
| spec = json.loads(pathlib.Path(args.shards).read_text()) | |
| out = pathlib.Path(args.out) | |
| out.mkdir(parents=True, exist_ok=True) | |
| for name, order in spec["order"].items(): | |
| with open(out / name, "w") as f: | |
| for index in order: | |
| if not spec.get("set") and not args.image_root: | |
| f.write(rows[index] + "\n") | |
| continue | |
| row = json.loads(rows[index]) | |
| row.update(spec.get("set", {})) | |
| if args.image_root: | |
| row["metadata"]["image_root"] = args.image_root | |
| f.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n") | |
| print(f"wrote {len(spec['order'])} shards to {out}") | |