Spaces:
Runtime error
Runtime error
UjjwalPardeshi commited on
Commit ·
6415da0
1
Parent(s): 2518b48
fix: emit structured START/END output even when env connection fails
Browse files- inference.py +7 -0
inference.py
CHANGED
|
@@ -256,6 +256,7 @@ async def main() -> None:
|
|
| 256 |
print(f"[DEBUG] API_KEY={'set' if API_KEY else 'NOT SET'} (source={'API_KEY' if os.getenv('API_KEY') else 'HF_TOKEN' if os.getenv('HF_TOKEN') else 'NONE'})", flush=True)
|
| 257 |
print(f"[DEBUG] Tasks to run: {tasks_to_run}", flush=True)
|
| 258 |
|
|
|
|
| 259 |
env = None
|
| 260 |
try:
|
| 261 |
if IMAGE_NAME:
|
|
@@ -269,11 +270,17 @@ async def main() -> None:
|
|
| 269 |
|
| 270 |
for task_id in tasks_to_run:
|
| 271 |
await run_task(env, client, task_id)
|
|
|
|
| 272 |
|
| 273 |
except Exception as exc:
|
| 274 |
print(f"[DEBUG] Fatal error: {exc}", flush=True)
|
| 275 |
|
| 276 |
finally:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
if env is not None:
|
| 278 |
try:
|
| 279 |
await env.close()
|
|
|
|
| 256 |
print(f"[DEBUG] API_KEY={'set' if API_KEY else 'NOT SET'} (source={'API_KEY' if os.getenv('API_KEY') else 'HF_TOKEN' if os.getenv('HF_TOKEN') else 'NONE'})", flush=True)
|
| 257 |
print(f"[DEBUG] Tasks to run: {tasks_to_run}", flush=True)
|
| 258 |
|
| 259 |
+
completed_tasks: set = set()
|
| 260 |
env = None
|
| 261 |
try:
|
| 262 |
if IMAGE_NAME:
|
|
|
|
| 270 |
|
| 271 |
for task_id in tasks_to_run:
|
| 272 |
await run_task(env, client, task_id)
|
| 273 |
+
completed_tasks.add(task_id)
|
| 274 |
|
| 275 |
except Exception as exc:
|
| 276 |
print(f"[DEBUG] Fatal error: {exc}", flush=True)
|
| 277 |
|
| 278 |
finally:
|
| 279 |
+
# Emit [START]/[END] for any tasks that didn't run (e.g. env connection failed)
|
| 280 |
+
for task_id in tasks_to_run:
|
| 281 |
+
if task_id not in completed_tasks:
|
| 282 |
+
log_start(task=task_id, env=BENCHMARK, model=MODEL_NAME)
|
| 283 |
+
log_end(task=task_id, success=False, steps=0, score=0.01, rewards=[])
|
| 284 |
if env is not None:
|
| 285 |
try:
|
| 286 |
await env.close()
|