MCPcopy Create free account
hub / github.com/Dizzy-K/AutoPT / _normalize_task_result

Function _normalize_task_result

analysis/loader.py:164–204  ·  view source on GitHub ↗
(
    payload: dict[str, Any],
    source_path: Path,
    benchmark_index: dict[str, dict[str, Any]],
)

Source from the content-addressed store, hash-verified

162
163
164def _normalize_task_result(
165 payload: dict[str, Any],
166 source_path: Path,
167 benchmark_index: dict[str, dict[str, Any]],
168) -> NormalizedResult:
169 details = payload.get("details", {})
170 if not isinstance(details, dict):
171 details = {}
172
173 benchmark_payload = _as_dict(details.get("benchmark"))
174 benchmark_name = str(payload.get("benchmark_name") or benchmark_payload.get("name") or "")
175 benchmark_metadata = _merge_benchmark_metadata(benchmark_name, benchmark_payload, benchmark_index)
176
177 model_payload = _as_dict(details.get("model"))
178 model_alias = _canonicalize_model_alias(
179 payload.get("model_alias") or model_payload.get("alias") or model_payload.get("name")
180 )
181
182 return NormalizedResult(
183 status=str(payload.get("status", "")),
184 runtime=_float_or_none(payload.get("runtime")),
185 benchmark_name=benchmark_name or str(benchmark_metadata.get("name", "")),
186 model_alias=model_alias,
187 arch=_infer_arch(details, source_path),
188 workflow_name=_normalize_result_namespace(details.get("workflow_name", "")),
189 prompt_bundle_name=str(details.get("prompt_bundle_name", "")),
190 difficulty=str(benchmark_metadata.get("difficulty", "")),
191 category=str(benchmark_metadata.get("category", benchmark_metadata.get("type", ""))),
192 benchmark_target=str(benchmark_metadata.get("target", "")),
193 ip_addr=str(payload.get("ip_addr", "")),
194 source_file=str(source_path),
195 source_dir=str(source_path.parent),
196 target=str(details.get("target") or benchmark_metadata.get("target", "")),
197 run_index=_int_or_none(details.get("round_index")),
198 commands=_as_list(details.get("commands")),
199 history=_as_list(details.get("history")),
200 prompts=_as_dict(details.get("prompts")),
201 benchmark=benchmark_metadata,
202 model=model_payload,
203 raw=payload,
204 )
205
206
207def _normalize_legacy_result(

Callers 1

_normalize_payloadFunction · 0.85

Calls 9

_as_dictFunction · 0.85
NormalizedResultClass · 0.85
_float_or_noneFunction · 0.85
_infer_archFunction · 0.85
_int_or_noneFunction · 0.85
_as_listFunction · 0.85

Tested by

no test coverage detected