Skip to content

Commit cd5aff9

Browse files
compute duration for modal
1 parent 0680c14 commit cd5aff9

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

commit0/configs/user.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ defaults:
22
- base
33
- _self_
44

5-
backend: local
5+
backend: modal

commit0/harness/execution_context.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import modal.io_streams
1212
from enum import StrEnum, auto
1313
from pathlib import Path
14+
import time
1415
from typing import Optional, Type
1516
from types import TracebackType
1617

@@ -170,6 +171,7 @@ def __init__(
170171

171172
def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
172173
"""Execute command on modal sandbox"""
174+
start_time = time.time()
173175
with modal.Volume.ephemeral() as vol:
174176
# copy back report.json if there is any
175177
report_file = Path(self.spec.repo_directory) / "report.json"
@@ -186,15 +188,12 @@ def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
186188
)
187189
self.sandbox.wait()
188190

189-
print("stdout")
190191
stdout = read_stream(self.sandbox.stdout)
191-
print(stdout)
192-
print("stderr")
193-
stderr = read_stream(self.sandbox.stderr)
194-
print(stderr)
192+
# stderr = read_stream(self.sandbox.stderr)
195193

196194
# return_code = self.sandbox.returncode
197195
# maybe use return_code for timeout info?
196+
# i dont know if sandboxes throw modal.TimeoutError
198197

199198
# copy over report.json from mount
200199
with (self.log_dir / "report.json").open("wb") as f:
@@ -203,8 +202,10 @@ def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]:
203202

204203
self.sandbox.terminate()
205204

206-
# TODO: add timing
207-
return stdout, False, 1.0
205+
end_time = time.time()
206+
207+
# TODO: add check for timeout
208+
return stdout, False, end_time - start_time
208209

209210
def __exit__(
210211
self,

0 commit comments

Comments
 (0)