File size: 1,816 Bytes
7009c01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
70
71
72
73
"""
Test to verify global environment singleton fallback works.

Tests that repeated /reset and /step calls without session_id
reuse the same environment instance and progress through tasks.
"""
import requests

BASE_URL = "https://nandukondreddy-config-debug-env.hf.space"

print("=" * 70)
print("GLOBAL ENV SINGLETON TEST (no session_id)")
print("=" * 70)
print()

print("[TEST] Calling /reset without session_id...")
r = requests.post(f"{BASE_URL}/reset", json={})
print(f"Status: {r.status_code}")
if r.status_code != 200:
    print(f"Error: {r.text}")
    exit(1)

data = r.json()
print(f"Initial task: {data.get('observation', {}).get('task_id')}")
print()

print("[TEST] Stepping through 15 requests with /step (no session_id)...")
print()

for step_num in range(1, 16):
    r = requests.post(
        f"{BASE_URL}/step",
        json={"fixed_config": "{}"}
    )
    
    if r.status_code != 200:
        print(f"[FAIL] Step {step_num} returned {r.status_code}")
        print(f"Error: {r.text}")
        exit(1)
    
    data = r.json()
    obs = data.get("observation", {})
    task_id = obs.get("task_id")
    reward = data.get("reward")
    done = data.get("done")
    
    print(f"Step {step_num:2d}: task_id={task_id:20s} reward={reward:.2f} done={done}")

print()
print("=" * 70)
print("FINAL TEST")
print("=" * 70)

# One more call to verify progression
r = requests.post(
    f"{BASE_URL}/step",
    json={"fixed_config": "{}"}  
)
data = r.json()
obs = data.get("observation", {})
final_task = obs.get("task_id")

print(f"After 16 steps: task_id={final_task}")

if final_task != "task1_json":
    print()
    print("[OK] SUCCESS: Task progressed beyond task1!")
    print(f"Currently on: {final_task}")
else:
    print()
    print("[ERROR] STILL STUCK ON TASK1 - Fallback not working")
    exit(1)