MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / inspect_result

Function inspect_result

codegeex/benchmark/inspect_result.py:73–278  ·  view source on GitHub ↗
(
        input_dir: str = None,
        input_file: str = None,
        output_dir: str = None,
        pass_at_k_outpath: str = None,
)

Source from the content-addressed store, hash-verified

71
72
73def inspect_result(
74 input_dir: str = None,
75 input_file: str = None,
76 output_dir: str = None,
77 pass_at_k_outpath: str = None,
78):
79 if input_dir is not None:
80 input_files = glob.glob(input_dir + "/*_results.jsonl")
81 else:
82 input_files = [input_file]
83
84 if output_dir is not None:
85 if not os.path.exists(output_dir):
86 os.makedirs(output_dir)
87 else:
88 output_dir = "/"
89
90 pass_at_k_outs = []
91 for input_file in input_files:
92 result_stats = defaultdict(dict)
93 df = None
94 incompleted = False
95 with open(input_file, "r") as f:
96 for i, line in enumerate(f):
97 obj = json.loads(line)
98 task_id = obj["task_id"]
99 language_type = task_id.split("/")[0].lower()
100 if language_type not in error_types:
101 if language_type == "humaneval":
102 language_type = "python"
103 elif language_type == "C++":
104 language_type = "cpp"
105 else:
106 incompleted = True
107 break
108 if task_id not in result_stats.keys():
109 default_stats = {}
110 default_stats["task_id"] = task_id
111 default_stats["n_sample"] = 0
112 for k in error_types[language_type]:
113 default_stats[k] = 0
114
115 result_stats[task_id] = default_stats.copy()
116 if df is None:
117 df = pd.DataFrame(columns=error_types[language_type])
118 result_stats[task_id]["n_sample"] += 1
119
120 if "failed" in obj["result"]:
121 error = obj["result"]
122 if language_type == "python":
123 if "assertionerror" in error.lower():
124 result_stats[task_id]["assertion error"] += 1
125 elif "syntax" in error.lower() or "indent" in error.lower() or "literal" in error.lower():
126 result_stats[task_id]["syntax error"] += 1
127 elif "not defined" in error.lower():
128 result_stats[task_id]["undefined error"] += 1
129 elif "timeout" in error.lower():
130 result_stats[task_id]["timeout error"] += 1

Callers

nothing calls this directly

Calls 3

estimate_pass_at_kFunction · 0.90
existsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected