Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- inference.py +8 -3
inference.py
CHANGED
|
@@ -95,9 +95,12 @@ def bounded_task_score(score: float) -> float:
|
|
| 95 |
return min(1.0 - SCORE_EPSILON, max(SCORE_EPSILON, score))
|
| 96 |
|
| 97 |
|
| 98 |
-
def log_end(success: bool, steps: int, rewards: list[float]) -> None:
|
| 99 |
rewards_str = ",".join(f"{reward:.2f}" for reward in rewards)
|
| 100 |
-
print(
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
|
| 103 |
def tool_schemas() -> list[dict[str, Any]]:
|
|
@@ -596,12 +599,14 @@ async def run_single_task_with_retries(
|
|
| 596 |
env = None
|
| 597 |
success = False
|
| 598 |
steps = 0
|
|
|
|
| 599 |
rewards: list[float] = []
|
| 600 |
try:
|
| 601 |
env = await connect_env()
|
| 602 |
summary = await run_single_task(client, env, task_id)
|
| 603 |
success = bool(summary["success"])
|
| 604 |
steps = int(summary["steps"])
|
|
|
|
| 605 |
rewards = list(summary["rewards"])
|
| 606 |
return summary
|
| 607 |
except (ConnectionClosedError, ConnectionError, TimeoutError, OSError) as exc:
|
|
@@ -623,7 +628,7 @@ async def run_single_task_with_retries(
|
|
| 623 |
except Exception:
|
| 624 |
pass
|
| 625 |
if env is not None:
|
| 626 |
-
log_end(success=success, steps=steps, rewards=rewards)
|
| 627 |
|
| 628 |
assert last_error is not None
|
| 629 |
raise last_error
|
|
|
|
| 95 |
return min(1.0 - SCORE_EPSILON, max(SCORE_EPSILON, score))
|
| 96 |
|
| 97 |
|
| 98 |
+
def log_end(success: bool, steps: int, score: float, rewards: list[float]) -> None:
|
| 99 |
rewards_str = ",".join(f"{reward:.2f}" for reward in rewards)
|
| 100 |
+
print(
|
| 101 |
+
f"[END] success={str(success).lower()} steps={steps} score={score:.3f} rewards={rewards_str}",
|
| 102 |
+
flush=True,
|
| 103 |
+
)
|
| 104 |
|
| 105 |
|
| 106 |
def tool_schemas() -> list[dict[str, Any]]:
|
|
|
|
| 599 |
env = None
|
| 600 |
success = False
|
| 601 |
steps = 0
|
| 602 |
+
score = 0.0
|
| 603 |
rewards: list[float] = []
|
| 604 |
try:
|
| 605 |
env = await connect_env()
|
| 606 |
summary = await run_single_task(client, env, task_id)
|
| 607 |
success = bool(summary["success"])
|
| 608 |
steps = int(summary["steps"])
|
| 609 |
+
score = float(summary["score"])
|
| 610 |
rewards = list(summary["rewards"])
|
| 611 |
return summary
|
| 612 |
except (ConnectionClosedError, ConnectionError, TimeoutError, OSError) as exc:
|
|
|
|
| 628 |
except Exception:
|
| 629 |
pass
|
| 630 |
if env is not None:
|
| 631 |
+
log_end(success=success, steps=steps, score=score, rewards=rewards)
|
| 632 |
|
| 633 |
assert last_error is not None
|
| 634 |
raise last_error
|