Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
hack timeout
  • Loading branch information
justinchiu-cohere committed Jan 28, 2025
commit 89371273646311c57b96f096a16faba04d66cc29
15 changes: 10 additions & 5 deletions commit0/harness/execution_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from e2b_code_interpreter import Sandbox
from strenum import StrEnum
from pathlib import Path
import tempfile
import time
from typing import Optional, Type
from types import TracebackType
Expand Down Expand Up @@ -261,15 +260,21 @@ def __init__(
self.sb.files.write(f["dest"].name, content) # type: ignore

def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
"""Execute command on E2B sandbox"""
"""Execute command on E2B sandbox
For timeouts, we could maybe use the error code or check whether the
sandbox is still alive.

The exit code is given by: result.exit_code

For now, we can just check if the sandbox is still alive.
"""
# TODO: setup timeout
start_time = time.time()
result = self.sb.commands.run(command)
return_code = result.exit_code
result = self.sb.commands.run(command, timeout=0)
for fname in self.files_to_collect:
with (self.log_dir / fname).open("w") as f:
f.write(self.sb.files.read(f"testbed/{fname}"))
timed_out = False # TODO: figure this out
timed_out = self.sb.is_running
end_time = time.time()
return result.stderr, timed_out, end_time - start_time

Expand Down
2 changes: 0 additions & 2 deletions commit0/harness/run_pytest_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

from typing import Iterator, Union
from commit0.harness.constants import (
ABSOLUTE_REPO_DIR,
EVAL_BACKENDS,
Files,
RELATIVE_REPO_DIR,
RUN_PYTEST_LOG_DIR,
RepoInstance,
SimpleInstance,
Expand Down
Loading