Support multi-sample promotion evidence
GeoIntel CI / docs-smoke (push) Has been cancelled
GeoIntel CI / contract-smoke (push) Has been cancelled

This commit is contained in:
Codex
2026-07-09 14:52:06 +02:00
parent f4af3b9eb0
commit 006819ca51
5 changed files with 142 additions and 17 deletions
@@ -109,24 +109,35 @@ def collect_positive_runs(
) -> dict[CandidateKey, list[dict[str, Any]]]:
best_by_candidate_sample: dict[tuple[CandidateKey, str], dict[str, Any]] = {}
portfolio_model_asset_id = portfolio.get("model_asset_id")
positive_runs: list[tuple[str, dict[str, Any]]] = []
for sample in portfolio.get("samples") or []:
sample_slug = str(sample.get("sample_slug") or "unknown")
for run in sample.get("runs") or []:
key = as_candidate_key(
run,
fallback_model_asset_id=str(portfolio_model_asset_id) if portfolio_model_asset_id else None,
fallback_tile_size=default_tile_size,
fallback_tile_overlap=default_tile_overlap,
)
f1 = numeric(run, "f1_score")
if key is None or f1 is None:
continue
enriched = dict(run)
enriched["sample_slug"] = sample_slug
existing = best_by_candidate_sample.get((key, sample_slug))
existing_f1 = numeric(existing or {}, "f1_score")
if existing is None or existing_f1 is None or f1 > existing_f1:
best_by_candidate_sample[(key, sample_slug)] = enriched
positive_runs.append((sample_slug, run))
for item in portfolio.get("items") or []:
sample_slug = str(item.get("sample_slug") or "unknown")
positive_runs.append((sample_slug, item))
for sample_slug, run in positive_runs:
key = as_candidate_key(
run,
fallback_model_asset_id=str(portfolio_model_asset_id) if portfolio_model_asset_id else None,
fallback_tile_size=default_tile_size,
fallback_tile_overlap=default_tile_overlap,
)
f1 = numeric(run, "f1_score")
if f1 is None:
f1 = numeric(run, "f1")
if key is None or f1 is None:
continue
enriched = dict(run)
enriched["f1_score"] = f1
enriched["sample_slug"] = sample_slug
existing = best_by_candidate_sample.get((key, sample_slug))
existing_f1 = numeric(existing or {}, "f1_score")
if existing is None or existing_f1 is None or f1 > existing_f1:
best_by_candidate_sample[(key, sample_slug)] = enriched
grouped: dict[CandidateKey, list[dict[str, Any]]] = defaultdict(list)
for (key, _sample_slug), run in best_by_candidate_sample.items():