MCPcopy Create free account
hub / github.com/OpenCodeInterpreter/OpenCodeInterpreter / script

Function script

evaluation/evalplus/evalplus/evalperf.py:250–361  ·  view source on GitHub ↗
(
    samples: str,
    dataset: str,
    output_dir: str,
    profile_n_correct: int = 10,
    max_n_samples: int = 50,
    max_parallelism: int = None,
    lazy_evaluation: bool = False,
    i_just_wanna_run: bool = False,
)

Source from the content-addressed store, hash-verified

248
249
250def script(
251 samples: str,
252 dataset: str,
253 output_dir: str,
254 profile_n_correct: int = 10,
255 max_n_samples: int = 50,
256 max_parallelism: int = None,
257 lazy_evaluation: bool = False,
258 i_just_wanna_run: bool = False,
259):
260 assert (
261 profile_n_correct <= max_n_samples
262 ), "profile_n_correct should be no more than max_n_samples"
263 assert dataset.endswith(".jsonl") and os.path.isfile(dataset)
264 assert samples.endswith(".jsonl") and os.path.isfile(samples)
265
266 console = Console() # printer
267
268 if lazy_evaluation:
269 console.print(
270 "Lazy evaluation is enabled: "
271 "It's faster but cannot address the order inconsistency on noisy testbed."
272 )
273
274 # load evalplus data
275 problems, expected_output = get_evalplus_data()
276
277 # load evalperf data
278 with open(dataset, "r") as f:
279 raw_data = [json.loads(l) for l in f]
280 tasks = {task["task_id"]: task for task in raw_data}
281
282 # setup max CPU threads
283 max_workers = max(1, multiprocessing.cpu_count() // 4)
284 if max_parallelism is not None:
285 max_workers = min(max_workers, max_parallelism)
286
287 model_name = os.path.basename(samples).replace(".jsonl", "")
288 result_path = os.path.join(output_dir, f"{(model_name + '_results')}.json")
289
290 # resume results
291 eval_results = {}
292 if not i_just_wanna_run and os.path.exists(result_path):
293 eval_results = json.load(open(result_path, "r"))
294 # pop tasks that have been evaluated
295 for evaluated_task in eval_results:
296 tasks.pop(evaluated_task, None)
297
298 console.print(f"Resumed {len(eval_results)} results from {result_path}")
299
300 # load model's solutions
301 samples = {
302 task["task_id"]: task["solution"][:max_n_samples]
303 for task in stream_jsonl(samples)
304 }
305
306 # log all tasks
307 console.print(f"{len(tasks)} tasks to evaluate :: result path: {result_path}")

Callers

nothing calls this directly

Calls 3

stream_jsonlFunction · 0.90
estimate_pass_at_kFunction · 0.90
get_evalplus_dataFunction · 0.85

Tested by

no test coverage detected