-
Notifications
You must be signed in to change notification settings - Fork 22
fix(evaluator): surface Gym sandbox bootstrap failures #1853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,11 +193,15 @@ async def wait_ready(self, handle: "GymHostHandle[OpenSandboxDriver]", timeout_s | |
| while asyncio.get_running_loop().time() < deadline: | ||
| try: | ||
| body = await asyncio.to_thread(self._get_json, handle.health_url, handle.headers) | ||
| except Exception as exc: | ||
| last_error = exc | ||
| else: | ||
| if body.get("status") == "ready": | ||
| return | ||
| error = body.get("error") | ||
| if isinstance(error, Mapping) and error.get("code") == "bootstrap_failed": | ||
| raise RuntimeError(f"job host {handle.host_id} failed during bootstrap: {error.get('message')}") | ||
| last_error = RuntimeError(f"host not ready: {body!r}") | ||
| except Exception as exc: | ||
| last_error = exc | ||
| await asyncio.sleep(_HEALTH_POLL_S) | ||
| raise TimeoutError( | ||
| f"job host {handle.host_id} at {handle.health_url} did not become ready within {timeout_s:g}s" | ||
|
|
@@ -210,8 +214,14 @@ def _get_json(self, url: str, headers: Mapping[str, str]) -> dict[str, Any]: | |
| with urlopen(request, timeout=10) as response: | ||
| payload = response.read() | ||
| except HTTPError as exc: | ||
| if exc.code == 503: | ||
| return {"status": "starting"} | ||
| # The Gym host uses an HTTP error response for both a transient bootstrap state and a | ||
| # terminal bootstrap failure. Preserve a JSON error envelope so wait_ready() can | ||
| # distinguish them; re-raise unrelated/non-JSON proxy errors. | ||
| if exc.code in {500, 503}: | ||
| try: | ||
| return json.loads(exc.read().decode("utf-8")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- changed hunk ---'
git diff -- packages/sandboxed_gym/src/sandboxed_gym/host/opensandbox.py
printf '%s\n' '--- local flow ---'
sed -n '150,245p' packages/sandboxed_gym/src/sandboxed_gym/host/opensandbox.py
printf '%s\n' '--- direct callers and related definitions ---'
rg -n -C 3 'wait_ready|_get_json|bootstrap_failed' packages/sandboxed_gym/src/sandboxed_gym/host/opensandbox.py packages/sandboxed_gymRepository: NVIDIA-NeMo/nemo-platform Length of output: 23904 🤖 get_repo_knowledge executed:
Length of output: 25737 Validate the decoded JSON shape before returning it. If 🤖 Prompt for AI Agents |
||
| except (UnicodeDecodeError, json.JSONDecodeError): | ||
| pass | ||
| raise | ||
| except URLError: | ||
| raise | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Do not convert permanent health errors into timeouts.
_get_jsonre-raises unrelated HTTP statuses and invalid or non-JSON error responses, but this catch intercepts all of them. A 404, 401, or malformed proxy response is polled untiltimeout_sand reported asTimeoutError, delaying the actual failure. Catch only retryable transport failures and let non-retryable health errors propagate.🤖 Prompt for AI Agents