Spaces:
Running
Running
Download scripts/pre_warm_space.py from yaswanth169/APISHIFT: direct link, hf CLI and curl.
- Browser
- Download file 641 Bytes
-
https://huggingface.co/spaces/yaswanth169/APISHIFT/resolve/main/scripts/pre_warm_space.py
- Command line
-
hf download hf://spaces/yaswanth169/APISHIFT/scripts/pre_warm_space.py
-
curl -L -o pre_warm_space.py https://huggingface.co/spaces/yaswanth169/APISHIFT/resolve/main/scripts/pre_warm_space.py
641 Bytes
| """Pre-warm the deployed HF Space so the demo doesn't hit a cold start. | |
| Call this 30 minutes before any live demo or evaluation. | |
| """ | |
| import asyncio | |
| import os | |
| import sys | |
| import httpx | |
| URL = os.getenv("ENV_BASE_URL", "https://yaswanth169-apishift-env.hf.space") | |
| async def main(): | |
| async with httpx.AsyncClient(timeout=15) as c: | |
| for path in ("/health", "/tasks", "/program"): | |
| try: | |
| r = await c.get(f"{URL}{path}") | |
| print(f"GET {path}: {r.status_code}") | |
| except Exception as e: | |
| print(f"GET {path}: {e!r}") | |
| if __name__ == "__main__": | |
| asyncio.run(main()) | |