File size: 2,053 Bytes
abe5ad8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
import requests
import time

BASE_URL = "http://localhost:8000"

def check_task(task_id):
    print(f"\n--- Testing Task: {task_id} ---")
    # 1. Reset
    r = requests.post(f"{BASE_URL}/reset", json={"task_name": task_id})
    if r.status_code != 200:
        print(f"❌ Reset failed: {r.status_code}")
        return False
    
    obs = r.json()
    print(f"βœ… Reset: Grid={obs['grid_width']}x{obs['grid_height']}, Target={obs['current_target']}")
    
    # 2. Check Score Range (should be 0.01 - 0.99)
    # At start, score should be around 0.01-0.10
    score = obs['score']
    if 0.01 <= score <= 0.99:
        print(f"βœ… Initial Score check: {score} (within 0.01-0.99)")
    else:
        print(f"❌ Initial Score out of range: {score}")
        return False
    
    # 3. Check Grader endpoint
    r = requests.get(f"{BASE_URL}/grade/{task_id}")
    if r.status_code != 200:
        print(f"❌ Grader endpoint failed: {r.status_code}")
        return False
    
    grade_res = r.json()
    print(f"βœ… Grader score: {grade_res['score']} (matches obs: {grade_res['score'] == score})")
    return True

def run_checks():
    # Wait for server to be ready
    for _ in range(5):
        try:
            requests.get(f"{BASE_URL}/health")
            break
        except:
            time.sleep(2)
            
    # Check Graders discovery
    r = requests.get(f"{BASE_URL}/graders")
    graders = r.json().get('graders', [])
    print(f"\n--- Discovering Graders ---")
    print(f"βœ… Found {len(graders)} graders: {graders}")
    
    expected = ["easy_delivery", "medium_delivery", "hard_delivery"]
    for t in expected:
        if t not in graders:
            print(f"❌ Missing task: {t}")
            return
            
    # Test each task
    for t in expected:
        if not check_task(t):
            print(f"\n❌ FINAL CHECK FAILED ON {t}")
            return
            
    print("\n" + "="*40)
    print("πŸ† ALL CHECKS PASSED: Environment is GOLDEN")
    print("="*40)

if __name__ == "__main__":
    run_checks()