Spaces:
Runtime error
Runtime error
UI-only mode: update scripts/run_online_daemon.py
Browse files12234510 unmodified lines161718192021228 unmodified lines3132333334353637383839404142434445464748495051524 unmodified lines5758596061626364656667686970717273747576777879808182838485865287888955565790919293#!/usr/bin/env python3"""Periodically run space/scripts/run_space_eval.py (1-hour live benchmark loop).""""""Local 1-hour loop: run eval locally, then push results to HF Space."""
from __future__ import annotations
10 unmodified lines
SPACE_ROOT = Path(__file__).resolve().parents[1]EVAL_SCRIPT = SPACE_ROOT / "scripts" / "run_space_eval.py"PUSH_SCRIPT = SPACE_ROOT / "scripts" / "push_results_to_hf.py"DEFAULT_INTERVAL_SECONDS = int( os.getenv( "TSFM_BENCH_INTERVAL_SECONDS",8 unmodified lines "--interval-minutes", type=int, default=max(1, DEFAULT_INTERVAL_SECONDS // 60), help="Minutes between collect + eval cycles (default: 60)", help="Minutes between collect + eval + push cycles (default: 60)", ) parser.add_argument( "--once", action="store_true", help="Run a single evaluation and exit", help="Run a single evaluation (+ push) and exit", ) parser.add_argument( "--no-push", action="store_true", help="Skip pushing results to Hugging Face", ) parser.add_argument( "--hf-endpoint", default=os.getenv("HF_ENDPOINT", "https://huggingface.co"), help="HF API endpoint for upload", ) return parser.parse_args()
4 unmodified lines return subprocess.run(cmd, cwd=str(SPACE_ROOT), check=False).returncode
def push_results(endpoint: str) -> int: cmd = [ sys.executable, str(PUSH_SCRIPT), "--endpoint", endpoint, ] logger.info("Pushing results to HF Space") return subprocess.run(cmd, cwd=str(SPACE_ROOT), check=False).returncode
def run_cycle(args: argparse.Namespace) -> int: code = run_eval() if code != 0: logger.error("Evaluation failed with exit code %s", code) return code if args.no_push: return 0 push_code = push_results(args.hf_endpoint) if push_code != 0: logger.error("HF push failed with exit code %s", push_code) return push_code
def main() -> None: args = parse_args() if args.once: raise SystemExit(run_eval()) raise SystemExit(run_cycle(args))
while True: code = run_eval() if code != 0: logger.error("Evaluation failed with exit code %s", code) run_cycle(args) logger.info("Sleeping %s minutes until next cycle", args.interval_minutes) time.sleep(args.interval_minutes * 60)
scripts/run_online_daemon.py+40-7