shortlist / code /scripts /probe.py
JagritGumber's picture
Add episodes, verdicts, census, fixes, code, training analysis and dataset card
a2b0c04 verified
Raw History Blame Contribute Delete
1.25 kB
"""Start each environment, save its /schema and a first reset(), and report whether it came up."""
import json
import sys
from pathlib import Path
import requests
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from shortlist.serve import APPS, ROOT, serve # noqa: E402
out = ROOT / "runs" / "probe"
out.mkdir(parents=True, exist_ok=True)
wanted = sys.argv[1:] or list(APPS)
for env in wanted:
try:
with serve(env) as url:
schema = requests.get(f"{url}/schema", timeout=30).json()
meta = requests.get(f"{url}/metadata", timeout=30).json()
reset = requests.post(f"{url}/reset", json={}, timeout=120)
body = reset.json() if reset.headers.get("content-type", "").startswith("application/json") else reset.text
(out / f"{env}.json").write_text(json.dumps({"schema": schema, "metadata": meta, "reset": body}, indent=2))
action = schema.get("action", {})
print(f"up {env:28s} action fields: {list(action.get('properties', {}))[:8]} reset {reset.status_code}")
except Exception as error: # noqa: BLE001 - a broken environment is a result, not a crash
print(f"DOWN {env:28s} {type(error).__name__}: {str(error)[:200]}")