1+ import argparse
2+ import os
3+ import json
4+ from tqdm import tqdm
5+ from wildcode .gen .util import trusted_exec
6+ from wildcode .eval .utils import (
7+ create_tempdir ,
8+ reliability_guard ,
9+ )
10+ def get_groundtruth (problems ):
11+ print ("\n Asserting the groundtruth..." )
12+ if os .path .exists ("checkpoint.txt" ):
13+ with open ("checkpoint.txt" , "r" ) as f :
14+ checkpoint = int (f .read ())
15+ else :
16+ checkpoint = 0
17+ for i , problem in tqdm (enumerate (problems [checkpoint :]), total = len (problems [checkpoint :])):
18+ task_id = problem ["task_id" ]
19+ try :
20+ with create_tempdir ():
21+ maximum_memory_bytes = 32 * 1024 * 1024 * 1024
22+ reliability_guard (maximum_memory_bytes = maximum_memory_bytes )
23+ trusted_exec (
24+ problem ["prompt" ] + "\n " + problem ["clean_canonical_solution" ],
25+ problem ["test" ],
26+ problem ["entry_point" ],
27+ )
28+ except :
29+ if i > 0 :
30+ with open ("checkpoint.txt" , "w" ) as f :
31+ f .write (str (i + checkpoint ))
32+ raise Exception (f"Error in task data/raw/{ task_id } " )
33+
34+
35+ def read_problems (jsonl_file ):
36+ with open (jsonl_file , "r" ) as f :
37+ problems = []
38+ for line in f :
39+ data = json .loads (line )
40+ problems .append (data )
41+ return problems
42+
43+
44+ def main ():
45+ parser = argparse .ArgumentParser ()
46+ parser .add_argument ("--samples" , type = str , help = "Path to the samples" )
47+ flags = parser .parse_args ()
48+
49+ problems = read_problems (flags .samples )
50+ get_groundtruth (problems )
51+ if __name__ == "__main__" :
52+ main ()
0 commit comments