@@ -65,17 +65,13 @@ def __init__(
65
65
self .log_dir = log_dir
66
66
67
67
@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 ]:
71
69
"""Exec"""
72
70
raise NotImplementedError
73
71
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 :
77
73
"""Write test output"""
78
- test_output_path = log_dir / "test_output.txt"
74
+ test_output_path = self . log_dir / "test_output.txt"
79
75
with open (test_output_path , "w" ) as f :
80
76
f .write (test_output )
81
77
if timed_out :
@@ -86,7 +82,6 @@ def write_test_output(
86
82
self .logger ,
87
83
)
88
84
89
-
90
85
def __enter__ (self ):
91
86
return self
92
87
@@ -123,19 +118,17 @@ def __init__(
123
118
for _ , f in files_to_copy .items ():
124
119
copy_to_container (self .container , f ["src" ], f ["dest" ]) # type: ignore
125
120
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 ]:
129
122
"""Exec"""
130
- output = exec_run_with_timeout (self .container , command , timeout )
123
+ output = exec_run_with_timeout (self .container , command , self . timeout )
131
124
132
125
# copy back report.json if there is any
133
126
report_file = Path (self .spec .repo_directory ) / "report.json"
134
127
# Run the test command inside the container to check if the file exists
135
128
exit_code , test_output = self ._exec_run (f"test -e { report_file } " )
136
129
# Check the exit code of the command
137
130
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" )
139
132
self ._delete_file_from_remote (report_file )
140
133
return output
141
134
@@ -183,10 +176,7 @@ def __init__(
183
176
image = image .copy_local_file (f ["src" ], f ["dest" ]) # type: ignore
184
177
self .image = image
185
178
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 ]:
190
180
"""Execute command on modal sandbox"""
191
181
192
182
with modal .Volume .ephemeral () as vol :
@@ -199,7 +189,7 @@ def exec_run_with_timeout(
199
189
f"{ command } && cp { str (report_file )} /vol/report.json" ,
200
190
image = self .image ,
201
191
cpu = 4.0 ,
202
- timeout = timeout ,
192
+ timeout = self . timeout ,
203
193
app = self .app ,
204
194
volumes = {"/vol" : vol },
205
195
)
@@ -219,7 +209,9 @@ def exec_run_with_timeout(
219
209
f .write (data )
220
210
221
211
self .sandbox .terminate ()
222
- import pdb ; pdb .set_trace ()
212
+ import pdb
213
+
214
+ pdb .set_trace ()
223
215
224
216
# TODO: add timing
225
217
return stdout , False , 1.0
0 commit comments