Skip to content

Commit c52e709

Browse files
cleanup docker exec
1 parent 4a6b95c commit c52e709

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

commit0/harness/execution_context.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def __init__(
5656
):
5757
"""Create the remote execution context
5858
59-
The execution context will persist for the lifetime of this object.
6059
The execution context can be a Docker container or Modal sandbox.
60+
The execution context may not persist for the lifetime of this object.
6161
"""
6262
self.spec = spec
6363
self.logger = logger
@@ -66,7 +66,7 @@ def __init__(
6666

6767
@abstractmethod
6868
def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
69-
"""Exec"""
69+
"""Execute a test command"""
7070
raise NotImplementedError
7171

7272
def write_test_output(self, test_output: str, timed_out: bool) -> None:
@@ -125,7 +125,8 @@ def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
125125
# copy back report.json if there is any
126126
report_file = Path(self.spec.repo_directory) / "report.json"
127127
# Run the test command inside the container to check if the file exists
128-
exit_code, test_output = self._exec_run(f"test -e {report_file}")
128+
exit_code, test_output = self.container.exec_run(
129+
f"test -e {report_file}", demux=True)
129130
# Check the exit code of the command
130131
if exit_code == 0:
131132
copy_from_container(
@@ -134,10 +135,6 @@ def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
134135
delete_file_from_container(self.container, str(report_file))
135136
return output
136137

137-
def _exec_run(self, command: str) -> tuple[int, str]:
138-
"""Exec"""
139-
return self.container.exec_run(command, demux=True)
140-
141138
def __exit__(
142139
self,
143140
exctype: Optional[Type[BaseException]],

0 commit comments

Comments
 (0)