MCPcopy Index your code
hub / github.com/evalplus/evalplus / trusted_exec

Function trusted_exec

evalplus/gen/util/__init__.py:7–30  ·  view source on GitHub ↗

Execute trusted code in place.

(code, inputs, entry_point, record_time=False, output_not_none=False)

Source from the content-addressed store, hash-verified

5
6
7def trusted_exec(code, inputs, entry_point, record_time=False, output_not_none=False):
8 """Execute trusted code in place."""
9 exec_globals = {}
10 exec(code, exec_globals)
11 fn = exec_globals[entry_point]
12
13 rtime = []
14 ret = []
15 for inp in inputs:
16 inp = deepcopy(inp)
17 if record_time:
18 start = time.time()
19 ret.append(fn(*inp))
20 rtime.append(time.time() - start)
21 else:
22 ret.append(fn(*inp))
23
24 if output_not_none:
25 ret = [i is not None for i in ret]
26
27 if record_time:
28 return ret, rtime
29 else:
30 return ret
31
32
33def trusted_check_exec(code, inputs, entry_point):

Callers 3

executeFunction · 0.90
get_groundtruthFunction · 0.90
trusted_check_execFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected