shamiur commited on
Commit
9b652dc
·
1 Parent(s): c8563f2

Part 32: add local_model_smoke.py test script

Browse files
Files changed (1) hide show
  1. scripts/local_model_smoke.py +87 -0
scripts/local_model_smoke.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: 2026 Shamiur Rashid Sunny
3
+ # SPDX-License-Identifier: AGPL-3.0-only
4
+ """Local model smoke test - hits the HF Space smoke endpoint.
5
+
6
+ WARNING: This freezes the entire HF Space for ~5-10 minutes.
7
+ Do not run while others are using the Space.
8
+ """
9
+
10
+ import sys
11
+ import time
12
+
13
+ import httpx
14
+
15
+
16
+ BASE = "https://shamiur-sunnyware.hf.space"
17
+
18
+
19
+ def main():
20
+ print("=" * 60)
21
+ print(" Local Model Smoke Test")
22
+ print("=" * 60)
23
+ print()
24
+ print("This freezes the HF Space for ~5-10 minutes.")
25
+ print("The WebUI will not respond during this test.")
26
+ print()
27
+ print("Starting test...")
28
+ print()
29
+
30
+ t0 = time.time()
31
+ try:
32
+ r = httpx.post(
33
+ BASE + "/api/local-model/smoke",
34
+ timeout=900.0,
35
+ )
36
+ except Exception as e:
37
+ print("[FAIL] Request error: " + type(e).__name__ + ": " + str(e))
38
+ return 1
39
+
40
+ elapsed = int(time.time() - t0)
41
+ print("Response received in " + str(elapsed) + " sec")
42
+ print()
43
+
44
+ if r.status_code != 200:
45
+ print("[FAIL] HTTP " + str(r.status_code))
46
+ print(r.text[:500])
47
+ return 1
48
+
49
+ try:
50
+ data = r.json()
51
+ except Exception as e:
52
+ print("[FAIL] Cannot parse JSON: " + str(e))
53
+ print(r.text[:500])
54
+ return 1
55
+
56
+ print("Total tests: " + str(data.get("total_tests")))
57
+ print("Passed: " + str(data.get("passed")))
58
+ print("Failed: " + str(data.get("failed")))
59
+ print("Total time: " + str(data.get("total_latency_ms")) + " ms")
60
+ print()
61
+ print("-" * 60)
62
+ print("Per-test results")
63
+ print("-" * 60)
64
+ print()
65
+
66
+ for entry in data.get("results", []):
67
+ name = entry.get("test", "?")
68
+ ok = entry.get("ok")
69
+ mark = "PASS" if ok else "FAIL"
70
+ print("[" + mark + "] " + name)
71
+ for k, v in entry.items():
72
+ if k in ("test", "ok"):
73
+ continue
74
+ print(" " + k + ": " + str(v)[:120])
75
+ print()
76
+
77
+ print("=" * 60)
78
+ if data.get("failed", 0) == 0:
79
+ print(" ALL LOCAL MODEL TESTS PASSED")
80
+ return 0
81
+ else:
82
+ print(" " + str(data.get("failed")) + " of " + str(data.get("total_tests")) + " tests FAILED")
83
+ return 1
84
+
85
+
86
+ if __name__ == "__main__":
87
+ sys.exit(main())