File size: 943 Bytes
360b3dd | 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 | #!/usr/bin/env python3
"""Export one JSON file per dataset item for frozen LLM generation jobs."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from common import read_json, write_json
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--manifest", type=Path, required=True)
parser.add_argument("--split", choices=("development", "test", "all"), default="all")
parser.add_argument("--out", type=Path, required=True)
args = parser.parse_args()
payload = read_json(args.manifest)
count = 0
for item in payload["items"]:
if args.split != "all" and item["split"] != args.split:
continue
write_json(args.out / f"{item['server_name']}.json", item)
count += 1
print(json.dumps({"exported": count, "output": str(args.out)}, indent=2))
return 0
if __name__ == "__main__":
raise SystemExit(main())
|