Spaces:
Running
Running
| #!/usr/bin/env python3 | |
| """Validate a community model forecast endpoint before leaderboard onboarding.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import sys | |
| from pathlib import Path | |
| REPO_ROOT = Path(__file__).resolve().parents[1] | |
| if str(REPO_ROOT) not in sys.path: | |
| sys.path.insert(0, str(REPO_ROOT)) | |
| from scripts.community_endpoint_protocol import validate_endpoint # noqa: E402 | |
| def parse_args() -> argparse.Namespace: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--endpoint-url", required=True, help="HTTPS POST /forecast endpoint") | |
| parser.add_argument("--model-id", required=True, help="Leaderboard display/model id") | |
| parser.add_argument("--auth-token-env", default=None, help="Optional bearer-token env var") | |
| parser.add_argument("--prediction-length", type=int, default=8) | |
| parser.add_argument("--context-length", type=int, default=64) | |
| parser.add_argument("--timeout", type=float, default=90.0) | |
| parser.add_argument( | |
| "--wait-seconds", | |
| type=float, | |
| default=0.0, | |
| help="Retry until this many seconds have elapsed while the public endpoint becomes ready", | |
| ) | |
| parser.add_argument("--retry-interval", type=float, default=15.0) | |
| parser.add_argument( | |
| "--allow-http", | |
| action="store_true", | |
| help="Allow http:// endpoint for localhost-only development checks", | |
| ) | |
| return parser.parse_args() | |
| def main() -> int: | |
| args = parse_args() | |
| summary = validate_endpoint( | |
| endpoint_url=args.endpoint_url, | |
| model_id=args.model_id, | |
| auth_token_env=args.auth_token_env, | |
| prediction_length=args.prediction_length, | |
| context_length=args.context_length, | |
| timeout=args.timeout, | |
| wait_seconds=args.wait_seconds, | |
| retry_interval=args.retry_interval, | |
| require_https=not args.allow_http, | |
| ) | |
| print(json.dumps(summary, indent=2)) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |