File size: 2,166 Bytes
d7adedb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import requests
import json
import time
import sys
import os

# Add root directory to sys.path for absolute imports
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

# Target URL (can be changed to your HF Space URL)
BASE_URL = "http://localhost:7860"

def run_checks():
    print(f"--- Starting Pre-Submission Validation on {BASE_URL} ---")
    
    # 1. Check /tasks
    try:
        resp = requests.get(f"{BASE_URL}/tasks")
        if resp.status_code == 200:
            data = resp.json()
            print("[PASS] /tasks returned 200")
            if "action_schema" in data:
                print("[PASS] Action schema found in /tasks")
            else:
                print("[FAIL] Action schema missing from /tasks")
        else:
            print(f"[FAIL] /tasks returned {resp.status_code}")
    except Exception as e:
        print(f"[ERROR] Could not reach /tasks: {e}")

    # 2. Check /reset
    try:
        resp = requests.post(f"{BASE_URL}/reset")
        if resp.status_code == 200:
            print("[PASS] /reset returned 200 and initial state")
        else:
            print(f"[FAIL] /reset returned {resp.status_code}")
    except Exception as e:
        print(f"[ERROR] Could not reach /reset: {e}")

    # 3. Check /baseline
    try:
        print("Checking /baseline (this may take 20-30 seconds)...")
        resp = requests.get(f"{BASE_URL}/baseline")
        if resp.status_code == 200:
            data = resp.json()
            print(f"[PASS] /baseline returned 200. Final Grade: {data.get('final_grade', 'N/A')}")
        else:
            print(f"[FAIL] /baseline returned {resp.status_code}")
    except Exception as e:
        print(f"[ERROR] Could not reach /baseline: {e}")

    # 4. Check /grader
    try:
        resp = requests.get(f"{BASE_URL}/grader")
        if resp.status_code == 200:
            print("[PASS] /grader returned 200")
        else:
            print(f"[FAIL] /grader returned {resp.status_code}")
    except Exception as e:
        print(f"[ERROR] Could not reach /grader: {e}")

    print("\n--- Validation Complete ---")

if __name__ == "__main__":
    run_checks()