"""Operator CLI for worker-local public dataset admission.""" from __future__ import annotations import json from pathlib import Path from typing import Annotated import typer from k1link.datasets.goose_admission import GooseAdmissionError, admit_goose_validation from k1link.datasets.goose_benchmark import ( benchmark_goose_current_ground, benchmark_goose_patchwork_ground, ) app = typer.Typer( add_completion=False, help="Admit public perception datasets without moving source data off worker D.", ) @app.command("admit-goose-validation") def admit_goose_validation_command( dataset_root: Annotated[ Path, typer.Option("--dataset-root", exists=True, file_okay=False, resolve_path=True), ], archive: Annotated[ Path | None, typer.Option("--archive", exists=True, dir_okay=False, resolve_path=True), ] = None, preview_points: Annotated[ int, typer.Option("--preview-points", min=1, max=50_000), ] = 50_000, ) -> None: """Verify the pinned GOOSE validation archive and import one native scan.""" try: manifest = admit_goose_validation( dataset_root, archive_path=archive, preview_points=preview_points, ) except GooseAdmissionError as exc: typer.echo(str(exc), err=True) raise typer.Exit(code=2) from exc typer.echo(json.dumps(manifest, ensure_ascii=False, sort_keys=True)) @app.command("benchmark-goose-current-ground") def benchmark_goose_current_ground_command( dataset_root: Annotated[ Path, typer.Option("--dataset-root", exists=True, file_okay=False, resolve_path=True), ], ) -> None: """Score the existing Mission Core ground baseline against GOOSE labels.""" try: report = benchmark_goose_current_ground(dataset_root) except GooseAdmissionError as exc: typer.echo(str(exc), err=True) raise typer.Exit(code=2) from exc typer.echo(json.dumps(report, ensure_ascii=False, sort_keys=True)) @app.command("benchmark-goose-patchwork-ground") def benchmark_goose_patchwork_ground_command( dataset_root: Annotated[ Path, typer.Option("--dataset-root", exists=True, file_okay=False, resolve_path=True), ], ) -> None: """Compare current and pinned Patchwork++ providers against GOOSE labels.""" try: report = benchmark_goose_patchwork_ground(dataset_root) except (GooseAdmissionError, ValueError) as exc: typer.echo(str(exc), err=True) raise typer.Exit(code=2) from exc typer.echo(json.dumps(report, ensure_ascii=False, sort_keys=True)) if __name__ == "__main__": app()