Skip to content

Commit f0476e7

Browse files
committed
update: update the workflows
1 parent f76aaf8 commit f0476e7

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

script/eval.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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("\nAsserting 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()

script/run.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NAMES=(chien jenny wenhao niklas hanhu ratna simon ming zhihan james)
1+
NAMES=(chien jenny wenhao niklas hanhu ratna simon ming zhihan james xiaoheng)
22

33
for name in "${NAMES[@]}"; do
44
# Copy all files for other names
@@ -8,6 +8,12 @@ done
88
flake8 data/clean/*.py --select=E9,F63,F7,F82 --show-source --statistics
99
python script/parse.py
1010

11+
gzip -c data/open-eval.jsonl > data/open-eval.jsonl.gz
12+
13+
# # used for WildCode evaluation
14+
# pip install -U wild-code
15+
# python script/eval.py --samples data/open-eval.jsonl
16+
1117
for name in "${NAMES[@]}"; do
1218

1319
for file in data/processed/*"$name"*wo_doc.py; do

0 commit comments

Comments
 (0)