MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / build_rows

Function build_rows

experiments/human_eval/build_model_human_eval_packet.py:135–201  ·  view source on GitHub ↗
(
    specs: Sequence[Tuple[str, str, Path]],
    users: Dict[str, Dict[str, Any]],
    *,
    reports_per_model: int,
    seed: int,
    abstract_chars: int,
    report_chars: int,
)

Source from the content-addressed store, hash-verified

133
134
135def build_rows(
136 specs: Sequence[Tuple[str, str, Path]],
137 users: Dict[str, Dict[str, Any]],
138 *,
139 reports_per_model: int,
140 seed: int,
141 abstract_chars: int,
142 report_chars: int,
143) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]]]:
144 blind_rows: List[Dict[str, Any]] = []
145 key_rows: List[Dict[str, Any]] = []
146 sample_index = 1
147 for model_key, model_name, output_dir in specs:
148 reports_path = report_jsonl_path(output_dir)
149 if not reports_path.exists():
150 print(f"Skipping missing reports for {model_key}: {reports_path}")
151 continue
152 reports = reservoir_sample_reports(reports_path, reports_per_model, seed + len(model_key))
153 lookup = load_episode_lookup(episode_papers_path(output_dir), (report_id(row) for row in reports))
154 for row in reports:
155 sample_id = f"HMODEL_{sample_index:05d}"
156 sample_index += 1
157 key = report_id(row)
158 paper_row = lookup.get(key, {})
159 user_id = str(row.get("user_id") or paper_row.get("user_id") or "")
160 blind_rows.append(
161 {
162 "sample_id": sample_id,
163 "user_profile": common.profile_text(users.get(user_id)),
164 "paper_title": common.truncate(row.get("title") or paper_row.get("title"), 500),
165 "paper_abstract": common.truncate(
166 row.get("abstract") or paper_row.get("abstract"),
167 abstract_chars,
168 ),
169 "paper_authors": common.truncate(row.get("authors") or paper_row.get("authors"), 500),
170 "recommendation_context": common.truncate(paper_row.get("reason") or paper_row.get("explanation"), 800),
171 "reading_report": compact_report_text(row, report_chars),
172 "HumanRelevance": "",
173 "HumanUsefulness": "",
174 "RecommendationDecisionHelpfulness": "",
175 "ReportFaithfulness": "",
176 "ReportSpecificity": "",
177 "ReportDecisionHelpfulness": "",
178 "comments": "",
179 }
180 )
181 key_rows.append(
182 {
183 "sample_id": sample_id,
184 "model_key": model_key,
185 "model_name": model_name,
186 "episode_id": row.get("episode_id") or paper_row.get("episode_id"),
187 "user_id": user_id,
188 "role_name": row.get("role_name") or paper_row.get("role_name"),
189 "date": row.get("date") or paper_row.get("date"),
190 "paper_id": row.get("paper_id") or paper_row.get("paper_id"),
191 "system_rank": paper_row.get("system_rank"),
192 "system_label": paper_row.get("system_label"),

Callers 1

mainFunction · 0.70

Calls 7

report_jsonl_pathFunction · 0.85
reservoir_sample_reportsFunction · 0.85
load_episode_lookupFunction · 0.85
episode_papers_pathFunction · 0.85
report_idFunction · 0.85
compact_report_textFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected