Download scripts/verify_hf_deployment.py from gitmodelmujtaba/medical-guidelines-kg: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/spaces/gitmodelmujtaba/medical-guidelines-kg/resolve/main/scripts/verify_hf_deployment.py
- Command line
-
hf download hf://spaces/gitmodelmujtaba/medical-guidelines-kg/scripts/verify_hf_deployment.py
-
curl -L -o verify_hf_deployment.py https://huggingface.co/spaces/gitmodelmujtaba/medical-guidelines-kg/resolve/main/scripts/verify_hf_deployment.py
2.2 kB
| import json | |
| import urllib.request | |
| SPACE_HOST = "https://gitmodelmujtaba-medical-guidelines-kg.hf.space" | |
| def test_api(): | |
| print(f"Testing connection to: {SPACE_HOST}") | |
| # 1. Test guidelines list | |
| req = urllib.request.Request(f"{SPACE_HOST}/api/guidelines", headers={"User-Agent": "Mozilla/5.0"}) | |
| with urllib.request.urlopen(req) as resp: | |
| assert resp.status == 200, f"Expected 200, got {resp.status}" | |
| data = json.loads(resp.read().decode("utf-8")) | |
| print("[PASS] /api/guidelines returned 200 OK") | |
| print(f" Found {len(data.get('guidelines', []))} guidelines:") | |
| for g in data.get("guidelines", []): | |
| print(f" - {g.get('guideline_id')}: {g.get('title')} (Triplets: {g.get('triplet_count')})") | |
| # 2. Test graph endpoint | |
| req = urllib.request.Request(f"{SPACE_HOST}/api/guidelines/RCOG-GTG-45/graph", headers={"User-Agent": "Mozilla/5.0"}) | |
| with urllib.request.urlopen(req) as resp: | |
| assert resp.status == 200, f"Expected 200, got {resp.status}" | |
| graph_data = json.loads(resp.read().decode("utf-8")) | |
| print(f"[PASS] /api/guidelines/RCOG-GTG-45/graph returned 200 OK") | |
| print(f" Nodes: {graph_data.get('total_nodes')}, Edges: {graph_data.get('total_edges')}") | |
| # 3. Test active learning status | |
| req = urllib.request.Request(f"{SPACE_HOST}/api/active-learning/status", headers={"User-Agent": "Mozilla/5.0"}) | |
| with urllib.request.urlopen(req) as resp: | |
| assert resp.status == 200 | |
| stats = json.loads(resp.read().decode("utf-8")) | |
| print(f"[PASS] /api/active-learning/status returned 200 OK") | |
| print(f" Stats: {stats}") | |
| # 4. Test HTML homepage | |
| req = urllib.request.Request(f"{SPACE_HOST}/", headers={"User-Agent": "Mozilla/5.0"}) | |
| with urllib.request.urlopen(req) as resp: | |
| assert resp.status == 200 | |
| html = resp.read().decode("utf-8") | |
| assert "Clinical Guideline Knowledge Graph Explorer" in html or "<title>" in html | |
| print(f"[PASS] / (homepage) served successfully ({len(html)} bytes)") | |
| print("\nAll Hugging Face deployment tests PASSED successfully!") | |
| if __name__ == "__main__": | |
| test_api() | |