(
dataset: str,
entry_point: str,
code: str,
inputs,
expected: List,
time_limits,
atol,
fast_check,
stat: Value,
details: Array,
progress: Value,
feedback: Value,
feedback_size: int,
)
| 152 | |
| 153 | |
| 154 | def unsafe_execute( |
| 155 | dataset: str, |
| 156 | entry_point: str, |
| 157 | code: str, |
| 158 | inputs, |
| 159 | expected: List, |
| 160 | time_limits, |
| 161 | atol, |
| 162 | fast_check, |
| 163 | stat: Value, |
| 164 | details: Array, |
| 165 | progress: Value, |
| 166 | feedback: Value, |
| 167 | feedback_size: int, |
| 168 | ): |
| 169 | with create_tempdir(): |
| 170 | # These system calls are needed when cleaning up tempdir. |
| 171 | import os |
| 172 | import shutil |
| 173 | |
| 174 | rmtree = shutil.rmtree |
| 175 | rmdir = os.rmdir |
| 176 | chdir = os.chdir |
| 177 | maximum_memory_bytes = None |
| 178 | reliability_guard(maximum_memory_bytes=maximum_memory_bytes) |
| 179 | exec_globals = {} |
| 180 | try: |
| 181 | with swallow_io(): |
| 182 | exec(code, exec_globals) |
| 183 | try: |
| 184 | fn = exec_globals[entry_point] |
| 185 | except KeyError as e: |
| 186 | raise f"Please rename your function to {entry_point} as there is no function named {entry_point}." |
| 187 | except BaseException as e: |
| 188 | raise MyCustomException("An error occurred.") |
| 189 | for i, inp in enumerate(inputs): |
| 190 | # try: |
| 191 | with time_limit(time_limits[i]): |
| 192 | out = fn(*inp) |
| 193 | |
| 194 | exp = expected[i] |
| 195 | exact_match = out == exp |
| 196 | |
| 197 | # ================================================ # |
| 198 | # ============== special oracles ================= # |
| 199 | if dataset == "mbpp": |
| 200 | if ( |
| 201 | "are_equivalent" == entry_point |
| 202 | ): # Mbpp/164 special oracle |
| 203 | exact_match = exact_match or True |
| 204 | elif "sum_div" == entry_point: # Mbpp/295 special oracle |
| 205 | exact_match = exact_match or out == 0 |
| 206 | elif entry_point in MBPP_OUTPUT_NOT_NONE_TASKS: |
| 207 | if isinstance(out, bool): |
| 208 | exact_match = out == exp |
| 209 | else: |
| 210 | exact_match = exp == (out is not None) |
| 211 |
nothing calls this directly
no test coverage detected