Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions nemo_skills/evaluation/evaluator/livecodebench.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,32 @@ async def execute_in_sandbox_with_retries(

async def is_sandbox_available(sandbox_config: dict) -> bool:
"""
Checks if the sandbox service is running and accessible by sending a test request.
Checks if the sandbox service is running, accessible, and can execute commands.

This function verifies sandbox availability by:
1. Establishing a connection to the sandbox service
2. Executing a test command ("true") to ensure the sandbox can process requests
3. Verifying the command completes successfully

Args:
sandbox_config: The configuration dictionary for the sandbox.
sandbox_config: The configuration dictionary for the sandbox service.

Returns:
True if a connection can be established, False otherwise.
True if the sandbox is accessible and can successfully execute commands,
False if connection fails, command execution fails, or any error occurs.
"""
LOG.info(f"Attempting to connect to sandbox with config: {sandbox_config}")
try:
async with sandbox_context(sandbox_config) as sandbox:
await execute_in_sandbox_with_retries(sandbox, 1, "true", language="shell", timeout=5)
LOG.info("Sandbox connection successful. Sandbox is available.")
return True
except httpx.NetworkError as e:
LOG.warning(f"Sandbox is unavailable due to a network error: {type(e).__name__} - {e}")
return False
except Exception as e:
LOG.warning(f"An unexpected error occurred while checking sandbox availability: {e}")
result, _ = await execute_in_sandbox_with_retries(sandbox, 1, "true", language="shell", timeout=5)
if result.get("process_status") != "completed":
LOG.warning(f"Sandbox responded but command failed: {result.get('stderr')}")
return False

LOG.info("Sandbox connection successful. Sandbox is available.")
return True
except (httpx.NetworkError, Exception) as e:
LOG.warning(f"Sandbox is unavailable or errored: {e}")
return False


Expand Down
Loading