| 477 | |
| 478 | |
| 479 | def build_parser() -> argparse.ArgumentParser: |
| 480 | parser = argparse.ArgumentParser( |
| 481 | description=( |
| 482 | "Two-stage screenshot judge. Reads a JSON config describing images and " |
| 483 | "prompts, calls the configured model, and prints a " |
| 484 | "JSON result with per-image records and the final verdict." |
| 485 | ) |
| 486 | ) |
| 487 | parser.add_argument("--config", required=True, help="Path to JSON config, or '-' for stdin.") |
| 488 | parser.add_argument("--workspace-dir", default="", help="Base directory for relative image paths.") |
| 489 | parser.add_argument("--output", default="", help="Write JSON result to this path instead of stdout.") |
| 490 | parser.add_argument( |
| 491 | "--auto-latest-run", |
| 492 | default="final_runs", |
| 493 | help=( |
| 494 | "When the config has no 'images' list, auto-discover screenshots from the " |
| 495 | "highest-numbered `<workspace-dir>/<this-value>/run_<id>/screenshots` folder. " |
| 496 | "Default: 'final_runs'. Pass '' (empty string) to disable auto-discovery." |
| 497 | ), |
| 498 | ) |
| 499 | parser.add_argument("--max-image-parse-retries", type=int, default=DEFAULT_IMAGE_PARSE_MAX_RETRIES) |
| 500 | parser.add_argument("--image-max-new-tokens", type=int, default=1024) |
| 501 | parser.add_argument("--final-max-new-tokens", type=int, default=8192) |
| 502 | parser.add_argument( |
| 503 | "--model-config", |
| 504 | default="", |
| 505 | help=( |
| 506 | "Path to a JSON/YAML config containing a top-level `model:` block. " |
| 507 | "If omitted, reads <workspace-dir>/config_snapshot/merged_config.yaml." |
| 508 | ), |
| 509 | ) |
| 510 | parser.add_argument("--timeout-seconds", type=int, default=120) |
| 511 | return parser |
| 512 | |
| 513 | |
| 514 | def main(argv: list[str] | None = None) -> int: |