Spaces:
Sleeping
Sleeping
Download test_server.py from ceoavinash/codearena-rl: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/ceoavinash/codearena-rl/resolve/main/test_server.py
- Command line
-
hf download hf://spaces/ceoavinash/codearena-rl/test_server.py
-
curl -L -o test_server.py https://huggingface.co/spaces/ceoavinash/codearena-rl/resolve/main/test_server.py
1.16 kB
| 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() | |