Spaces:
Runtime error
Runtime error
Terry Zhuo commited on
Commit ·
9fd6b97
1
Parent(s): 89eb067
update
Browse files11 unmodified lines12131415161718197 unmodified lines272829303132333435363738394015 unmodified lines56575859606162636465666781 unmodified lines14915015115215315415515615715815916016116221 unmodified lines18418518618718818919019119219319419519619719819920020120220320420520611 unmodified linesfrom warnings import warnimport numpy as npfrom termcolor import cprintfrom tqdm import tqdmfrom bigcodebench.data import get_bigcodebench, get_bigcodebench_hash, load_solutionsfrom bigcodebench.data.utils import CACHE_DIR7 unmodified linescache_file = os.path.join(CACHE_DIR, f"{hashcode}.pkl")if os.path.exists(cache_file):if check_gt_only:os.remove(cache_file)else:print(f"Load from ground-truth from {cache_file}")with open(cache_file, "rb") as f:return pickle.load(f)os.makedirs(CACHE_DIR, exist_ok=True)print("\nAsserting the groundtruth...")tbegin = time.time()with ProcessPoolExecutor(max_workers=n_workers) as executor:15 unmodified linesfutures.append(executor.submit(trusted_check, *args))n_samples += 1for future in tqdm(as_completed(futures), total=n_samples):result = future.result()expected_time[result["task_id"]] = result["time"]print(f"Expected outputs computed in {time.time() - tbegin:.2f}s")if any(expected_time.values()):with open(cache_file, "wb") as f:pickle.dump(expected_time, f)81 unmodified lineseval_results = defaultdict(list) # task_id ->remainings = set()print("Reading samples...")for sample in tqdm(load_solutions(samples)):task_id = sample["task_id"]if task_id not in problems:warn(f"Task {task_id} is found in the samples but not found in the dataset")continuesolution = (sample["solution"]21 unmodified linesassert n_samples == len(remainings), "Missing problems in unfinished"assert len(completion_id) == len(problems), "Missing problems in samples"# def stucking_checker():# not_done = futures# while len(not_done) > 0:# done, not_done = wait(not_done, timeout=240, return_when=FIRST_COMPLETED)# if len(done) == 0:# warn("No samples have finished testing in the last 240s")# warn(f"{len(remainings)} samples to be tested: {remainings}")# threading.Thread(target=stucking_checker).start()for future in tqdm(as_completed(futures), total=n_samples):result = future.result()remainings.remove(result["_identifier"])eval_results[result["task_id"]].append(result)# sort the results for each problem by completion_idfor task_id, task_results in eval_results.items():task_results.sort(key=lambda x: x["completion_id"])11 unmodified lines1213141516177 unmodified lines2526272829303132333415 unmodified lines5051525354555657585981 unmodified lines14114214314414514614714814915021 unmodified lines17217317417517617717817918018118211 unmodified linesfrom warnings import warnimport numpy as npfrom bigcodebench.data import get_bigcodebench, get_bigcodebench_hash, load_solutionsfrom bigcodebench.data.utils import CACHE_DIR7 unmodified linescache_file = os.path.join(CACHE_DIR, f"{hashcode}.pkl")if os.path.exists(cache_file):if check_gt_only:with open(cache_file, "rb") as f:return pickle.load(f)os.makedirs(CACHE_DIR, exist_ok=True)tbegin = time.time()with ProcessPoolExecutor(max_workers=n_workers) as executor:15 unmodified linesfutures.append(executor.submit(trusted_check, *args))n_samples += 1for future in as_completed(futures):result = future.result()expected_time[result["task_id"]] = result["time"]if any(expected_time.values()):with open(cache_file, "wb") as f:pickle.dump(expected_time, f)81 unmodified lineseval_results = defaultdict(list) # task_id ->remainings = set()for sample in load_solutions(samples):task_id = sample["task_id"]if task_id not in problems:continuesolution = (sample["solution"]21 unmodified linesassert n_samples == len(remainings), "Missing problems in unfinished"assert len(completion_id) == len(problems), "Missing problems in samples"for future in as_completed(futures):result = future.result()remainings.remove(result["_identifier"])eval_results[result["task_id"]].append(result)# sort the results for each problem by completion_idfor task_id, task_results in eval_results.items():task_results.sort(key=lambda x: x["completion_id"])
app.py+4-28