File size: 1,160 Bytes
8599a81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import httpx
import time
import subprocess
import sys
import os

def main():
    print("Starting server...")
    server_process = subprocess.Popen([sys.executable, "-m", "uvicorn", "server.app:app", "--port", "7860"])
    
    time.sleep(3) # Wait for server to start
    
    try:
        print("Testing /reset...")
        res = httpx.post("http://localhost:7860/reset", json={"task_id": "auto"})
        res.raise_for_status()
        
        print("Running inference.py...")
        # Just run easy task for one episode to save time
        env = os.environ.copy()
        env["CODEARENA_TASK"] = "easy-1"
        # We don't have a real openai key or hf model downloaded, so it will hit fallback and succeed
        subprocess.run([sys.executable, "inference.py", "--backend", "openai"], env=env, check=True)
        
        print("Running plot_rewards.py...")
        subprocess.run([sys.executable, "plot_rewards.py"], check=True)
        
        print("All tests passed.")
    except Exception as e:
        print("Test failed:", e)
    finally:
        server_process.terminate()
        server_process.wait()

if __name__ == "__main__":
    main()