(
dataset: str,
entry_point: str,
code: str,
inputs,
expected: List,
time_limits,
atol,
fast_check,
stat, # Value
details, # Array
progress, # Value
)
| 120 | |
| 121 | |
| 122 | def unsafe_execute( |
| 123 | dataset: str, |
| 124 | entry_point: str, |
| 125 | code: str, |
| 126 | inputs, |
| 127 | expected: List, |
| 128 | time_limits, |
| 129 | atol, |
| 130 | fast_check, |
| 131 | stat, # Value |
| 132 | details, # Array |
| 133 | progress, # Value |
| 134 | ): |
| 135 | with create_tempdir(): |
| 136 | # These system calls are needed when cleaning up tempdir. |
| 137 | import os |
| 138 | import shutil |
| 139 | |
| 140 | rmtree = shutil.rmtree |
| 141 | rmdir = os.rmdir |
| 142 | chdir = os.chdir |
| 143 | reliability_guard(maximum_memory_bytes=query_maximum_memory_bytes()) |
| 144 | exec_globals = {} |
| 145 | try: |
| 146 | with swallow_io(): |
| 147 | exec(code, exec_globals) |
| 148 | fn = exec_globals[entry_point] |
| 149 | |
| 150 | for i, inp in enumerate(inputs): |
| 151 | try: |
| 152 | with time_limit(time_limits[i]): |
| 153 | with swallow_io(): |
| 154 | out = fn(*inp) |
| 155 | |
| 156 | exp = expected[i] |
| 157 | exact_match = out == exp |
| 158 | |
| 159 | # ================================================ # |
| 160 | # ============== special oracles ================= # |
| 161 | if dataset == "mbpp": |
| 162 | if "are_equivalent" == entry_point: # Mbpp/164 special oracle |
| 163 | exact_match = exact_match or True |
| 164 | elif "sum_div" == entry_point: # Mbpp/295 special oracle |
| 165 | exact_match = exact_match or out == 0 |
| 166 | elif "surface_Area" == entry_point: # Mbpp/581 special oracle |
| 167 | exact_match = ( |
| 168 | exact_match or abs(out - _surface_Area(*inp)) <= atol |
| 169 | ) |
| 170 | elif ( |
| 171 | "digit_distance_nums" == entry_point |
| 172 | ): # Mbpp/558 special oracle |
| 173 | exact_match = exact_match or out == _digit_distance_nums( |
| 174 | *inp |
| 175 | ) |
| 176 | elif entry_point in MBPP_OUTPUT_SET_EQ_TASKS: |
| 177 | exact_match = set(out) == set(exp) |
| 178 | elif entry_point in MBPP_OUTPUT_NOT_NONE_TASKS: |
| 179 | # exp is True if not None |
nothing calls this directly
no test coverage detected