| |
| 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") |
|
|