submit / ops /wait_space.py
sahel-sh's picture
deploy portal
f0fdd1d verified
Raw History Blame Contribute Delete
531 Bytes
import sys, time
sys.path.insert(0, str(__import__("pathlib").Path(__file__).resolve().parent))
from deploy import load_env
from huggingface_hub import HfApi
api = HfApi(token=load_env()["HF_TOKEN"]); t0 = time.time(); time.sleep(6); stage = None
while time.time() - t0 < 420:
stage = api.get_space_runtime("sahel-sh/submit").stage
if stage in ("RUNNING", "RUNTIME_ERROR", "BUILD_ERROR", "CONFIG_ERROR"): break
time.sleep(8)
print(f"space stage after {time.time()-t0:.0f}s: {stage}")
if stage != "RUNNING": sys.exit(1)