APISHIFT / scripts /pre_warm_space.py
yaswanth169's picture
Initial APIShift env push
3040bf7 verified
Raw History Blame Contribute Delete
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())