Spaces:
Runtime error
Runtime error
| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| from pathlib import Path | |
| import argparse | |
| import sys | |
| ROOT = Path(__file__).resolve().parents[1] | |
| SRC = ROOT / "src" | |
| if str(SRC) not in sys.path: | |
| sys.path.insert(0, str(SRC)) | |
| from app_kit.sponsor_policy import ( | |
| DEFAULT_POLICY_RELATIVE_PATH, | |
| DEFAULT_WAIVER_RELATIVE_PATH, | |
| check_sponsor_policy, | |
| format_sponsor_policy_result, | |
| ) | |
| def build_parser() -> argparse.ArgumentParser: | |
| parser = argparse.ArgumentParser(description="Check sponsor-aligned models against the registry.") | |
| parser.add_argument( | |
| "--model-registry", | |
| type=Path, | |
| default=Path("configs/model_registry.yaml"), | |
| help="Path to configs/model_registry.yaml or a compatible registry file.", | |
| ) | |
| parser.add_argument( | |
| "--policy", | |
| type=Path, | |
| default=Path(DEFAULT_POLICY_RELATIVE_PATH), | |
| help="Path to the sponsor model policy file.", | |
| ) | |
| parser.add_argument( | |
| "--waiver", | |
| type=Path, | |
| default=Path(DEFAULT_WAIVER_RELATIVE_PATH), | |
| help="Optional waiver file path. If present and valid, mismatches pass with a warning.", | |
| ) | |
| return parser | |
| def main(argv: list[str] | None = None) -> int: | |
| parser = build_parser() | |
| args = parser.parse_args(argv) | |
| waiver_path = args.waiver if args.waiver.exists() else None | |
| result = check_sponsor_policy(args.model_registry, args.policy, waiver_path) | |
| stdout, stderr, exit_code = format_sponsor_policy_result(result) | |
| if stdout: | |
| print(stdout) | |
| if stderr: | |
| print(stderr, file=sys.stderr) | |
| return exit_code | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |