Spaces:
Running
Running
Download scripts/check_cloud_health.py from ThinkcatLab/LiveHouse-TS: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/ThinkcatLab/LiveHouse-TS/resolve/main/scripts/check_cloud_health.py
- Command line
-
hf download hf://spaces/ThinkcatLab/LiveHouse-TS/scripts/check_cloud_health.py
-
curl -L -o check_cloud_health.py https://huggingface.co/spaces/ThinkcatLab/LiveHouse-TS/resolve/main/scripts/check_cloud_health.py
1.06 kB
| #!/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() | |