#!/usr/bin/env python3 """Lightweight remote watchdog; no model dependencies or local operator needed.""" from __future__ import annotations import json import os import time from urllib.request import Request, urlopen from urllib.error import HTTPError, URLError def main(): url = os.getenv("HF_SPACE_URL", "https://thinkcatlab-livehouse-ts.hf.space").rstrip("/") error = "" for attempt in range(4): try: with urlopen(Request(url + "/healthz", headers={"User-Agent":"LiveHouse-TS-organization-healthcheck"}), timeout=45) as response: payload = json.load(response) if not payload.get("ok"): raise ValueError("Remote evaluator/checkpoint is not healthy") print(json.dumps(payload, indent=2)) return except (HTTPError, URLError, TimeoutError, ValueError) as exc: error = str(exc) if attempt < 3: time.sleep(30) raise SystemExit("Cloud health check failed: " + error) if __name__ == "__main__": main()