Skip to content

Commit f3dfbce

Browse files
cleanup api and ruff
1 parent 304c8d5 commit f3dfbce

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

commit0/harness/execution_context.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,13 @@ def __init__(
6565
self.log_dir = log_dir
6666

6767
@abstractmethod
68-
def exec_run_with_timeout(
69-
self, command: str, timeout: int
70-
) -> tuple[str, bool, float]:
68+
def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
7169
"""Exec"""
7270
raise NotImplementedError
7371

74-
def write_test_output(
75-
self, log_dir: Path, test_output: str, timed_out: bool
76-
) -> None:
72+
def write_test_output(self, test_output: str, timed_out: bool) -> None:
7773
"""Write test output"""
78-
test_output_path = log_dir / "test_output.txt"
74+
test_output_path = self.log_dir / "test_output.txt"
7975
with open(test_output_path, "w") as f:
8076
f.write(test_output)
8177
if timed_out:
@@ -86,7 +82,6 @@ def write_test_output(
8682
self.logger,
8783
)
8884

89-
9085
def __enter__(self):
9186
return self
9287

@@ -123,19 +118,17 @@ def __init__(
123118
for _, f in files_to_copy.items():
124119
copy_to_container(self.container, f["src"], f["dest"]) # type: ignore
125120

126-
def exec_run_with_timeout(
127-
self, command: str, timeout: int, log_dir: Path,
128-
) -> tuple[str, bool, float]:
121+
def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
129122
"""Exec"""
130-
output = exec_run_with_timeout(self.container, command, timeout)
123+
output = exec_run_with_timeout(self.container, command, self.timeout)
131124

132125
# copy back report.json if there is any
133126
report_file = Path(self.spec.repo_directory) / "report.json"
134127
# Run the test command inside the container to check if the file exists
135128
exit_code, test_output = self._exec_run(f"test -e {report_file}")
136129
# Check the exit code of the command
137130
if exit_code == 0:
138-
self._copy_from_remote(report_file, log_dir / "report.json")
131+
self._copy_from_remote(report_file, self.log_dir / "report.json")
139132
self._delete_file_from_remote(report_file)
140133
return output
141134

@@ -183,10 +176,7 @@ def __init__(
183176
image = image.copy_local_file(f["src"], f["dest"]) # type: ignore
184177
self.image = image
185178

186-
187-
def exec_run_with_timeout(
188-
self, command: str, timeout: int, log_dir: Path,
189-
) -> tuple[str, bool, float]:
179+
def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
190180
"""Execute command on modal sandbox"""
191181

192182
with modal.Volume.ephemeral() as vol:
@@ -199,7 +189,7 @@ def exec_run_with_timeout(
199189
f"{command} && cp {str(report_file)} /vol/report.json",
200190
image=self.image,
201191
cpu=4.0,
202-
timeout=timeout,
192+
timeout=self.timeout,
203193
app=self.app,
204194
volumes={"/vol": vol},
205195
)
@@ -219,7 +209,9 @@ def exec_run_with_timeout(
219209
f.write(data)
220210

221211
self.sandbox.terminate()
222-
import pdb; pdb.set_trace()
212+
import pdb
213+
214+
pdb.set_trace()
223215

224216
# TODO: add timing
225217
return stdout, False, 1.0

commit0/harness/run_pytest_ids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ def main(
9494
try:
9595
with execution_context(spec, logger, timeout, log_dir, files_to_copy) as context:
9696
output, timed_out, total_runtime = context.exec_run_with_timeout(
97-
"/bin/bash /eval.sh", timeout, log_dir,
97+
"/bin/bash /eval.sh"
9898
)
9999
logger.info(output)
100100
test_output = extract_test_output(
101101
output, "--json-report --json-report-file=report.json"
102102
)
103-
context.write_test_output(log_dir, test_output, timed_out)
103+
context.write_test_output(test_output, timed_out)
104104
print(test_output)
105105
except EvaluationError as e:
106106
error_msg = (

0 commit comments

Comments
 (0)