Sathvik-kota commited on
Commit
75c6ae4
·
verified ·
1 Parent(s): 095a28c

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. run_all_samples.py +45 -0
run_all_samples.py CHANGED
@@ -7,6 +7,51 @@ from datetime import datetime
7
  from fastapi.testclient import TestClient
8
  from app import app as fastapi_app # FIXED IMPORT
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  # ----------------------------------------------------
12
  # Paths
 
7
  from fastapi.testclient import TestClient
8
  from app import app as fastapi_app # FIXED IMPORT
9
 
10
+ from fastapi import HTTPException
11
+ from fastapi.responses import PlainTextResponse
12
+
13
+ # List files in samples/
14
+ @app.get("/debug-list-samples")
15
+ def debug_list_samples():
16
+ base = Path(__file__).parent
17
+ samples = base / "samples"
18
+ if not samples.exists():
19
+ raise HTTPException(status_code=404, detail="samples/ folder not found")
20
+ items = []
21
+ for p in sorted(samples.rglob("*")):
22
+ if p.is_file():
23
+ items.append(str(p.relative_to(base)))
24
+ return {"count": len(items), "files": items}
25
+
26
+ # List files in results/ (what we expect run_all_samples to write)
27
+ @app.get("/debug-list-results")
28
+ def debug_list_results():
29
+ base = Path(__file__).parent
30
+ results = base / "results"
31
+ if not results.exists():
32
+ return {"count": 0, "files": []}
33
+ items = []
34
+ for p in sorted(results.rglob("*")):
35
+ if p.is_file():
36
+ items.append(str(p.relative_to(base)))
37
+ return {"count": len(items), "files": items}
38
+
39
+ # Return tail of run_all_samples.log (first/last lines) as plain text
40
+ @app.get("/debug-get-log", response_class=PlainTextResponse)
41
+ def debug_get_log(lines: int = 200):
42
+ base = Path(__file__).parent
43
+ log_file = base / "run_all_samples.log"
44
+ if not log_file.exists():
45
+ return "NO LOG FILE"
46
+ try:
47
+ text = log_file.read_text(encoding="utf-8", errors="ignore")
48
+ parts = text.splitlines()
49
+ # return last `lines` lines
50
+ out = "\n".join(parts[-lines:])
51
+ return out
52
+ except Exception as e:
53
+ return f"ERROR reading log: {e}"
54
+
55
 
56
  # ----------------------------------------------------
57
  # Paths