11
11
import modal .io_streams
12
12
from enum import StrEnum , auto
13
13
from pathlib import Path
14
+ import time
14
15
from typing import Optional , Type
15
16
from types import TracebackType
16
17
@@ -170,6 +171,7 @@ def __init__(
170
171
171
172
def exec_run_with_timeout (self , command : str ) -> tuple [str , bool , float ]:
172
173
"""Execute command on modal sandbox"""
174
+ start_time = time .time ()
173
175
with modal .Volume .ephemeral () as vol :
174
176
# copy back report.json if there is any
175
177
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]:
186
188
)
187
189
self .sandbox .wait ()
188
190
189
- print ("stdout" )
190
191
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)
195
193
196
194
# return_code = self.sandbox.returncode
197
195
# maybe use return_code for timeout info?
196
+ # i dont know if sandboxes throw modal.TimeoutError
198
197
199
198
# copy over report.json from mount
200
199
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]:
203
202
204
203
self .sandbox .terminate ()
205
204
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
208
209
209
210
def __exit__ (
210
211
self ,
0 commit comments