File size: 1,719 Bytes
77731f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
from __future__ import annotations

import argparse
from pathlib import Path

from _common import REPO_ROOT, copy_file, ensure_dir, read_jsonl, write_json


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description="Build or copy CM-EVS candidate metadata.")
    parser.add_argument("--tiny", action="store_true", help="Use the bundled tiny metadata example.")
    parser.add_argument("--input", type=Path, default=None, help="Existing candidate JSONL to normalize/copy.")
    parser.add_argument("--output-dir", type=Path, default=Path("outputs/tiny"), help="Run output directory.")
    return parser.parse_args()


def main() -> None:
    args = parse_args()
    metadata_dir = ensure_dir(args.output_dir / "metadata")
    out_path = metadata_dir / "candidates.jsonl"

    if args.tiny:
        src = REPO_ROOT / "examples" / "metadata" / "candidates.jsonl"
        mode = "tiny"
    elif args.input:
        src = args.input
        mode = "copy"
    else:
        raise SystemExit("Provide --tiny or --input. Full generation is handled by pipelines/run_full_pipeline.py.")

    rows = read_jsonl(src)
    copy_file(src, out_path)
    write_json(
        metadata_dir / "source_manifest.json",
        {
            "mode": mode,
            "candidate_file": str(out_path.relative_to(args.output_dir)),
            "num_candidates": len(rows),
            "num_valid_candidates": sum(1 for row in rows if bool(row.get("valid", True))),
            "note": "Tiny mode validates the metadata contract and does not reproduce paper-scale results.",
        },
    )
    print(f"Wrote {out_path} with {len(rows)} candidates")


if __name__ == "__main__":
    main()