File size: 1,310 Bytes
f8cab22 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #!/usr/bin/env python3
from huggingface_hub import HfApi
from urllib.request import urlopen
import os
import time
repo_id = os.environ.get(
"SPACE_REPO",
"AXONVERTEX-AI-RESEARCH/GraphShieldMistral",
)
owner, name = repo_id.split("/", 1)
app_url = f"https://{owner}-{name}.hf.space".lower()
api = HfApi()
info = api.space_info(repo_id=repo_id)
print(f"repo: {info.id}")
print(f"private: {info.private}")
print(f"sdk: {info.sdk}")
assert info.private is False
assert info.sdk == "static"
for _ in range(36):
runtime = api.get_space_runtime(repo_id=repo_id)
stage = str(runtime.stage)
print(f"runtime stage: {stage}")
if "RUNNING" in stage:
break
if "ERROR" in stage:
raise SystemExit(f"FAIL: Space runtime entered {stage}")
time.sleep(10)
else:
raise SystemExit("FAIL: Space did not reach RUNNING state")
with urlopen(app_url, timeout=30) as response:
body = response.read().decode("utf-8", errors="replace")
status = response.status
print(f"anonymous app URL: {app_url}")
print(f"HTTP status: {status}")
assert status == 200
assert "GraphShieldMistral scenario clusters" in body
assert "GraphShieldMistral interactive policy-graph explorer" in body
print("PASS: public static Space is running")
print("PASS: anonymous interactive graph access")
|