Spaces:
Running
Running
Deploy eval-card-registry service
Browse filesFiles changed (3)
6 unmodified lines789101112519 unmodified lines532533534535536537538539604 unmodified lines1144114511461147114811496 unmodified linessync Batch sync one or all EEE configs → eval_results table"""import jsonfrom pathlib import Pathfrom typing import Optional519 unmodified linesby_id[entry["id"]] = _merge_benchmark(by_id[entry["id"]], entry)else:by_id[entry["id"]] = entryreturn list(by_id.values())# ------------------------------------------------------------------# Families — translate seed/families.yaml's nested {slug: {fields}}# shape into flat dicts ready for upsert. The YAML uses the slug as604 unmodified linesstore.set_table("canonical_inference_platforms", inf_plat_df)typer.echo(f" inference_platforms: {len(inf_plat_rows)}")# Derive denormalized parent-walk caches now that all canonical_models# rows are present. `model_group_id` and `lineage_origin_model_org_id`# are computed from `parents` and need the full graph to be in place.6 unmodified lines7891011121314519 unmodified lines534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630604 unmodified lines12351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412956 unmodified linessync Batch sync one or all EEE configs → eval_results table"""import jsonimport reimport unicodedatafrom pathlib import Pathfrom typing import Optional519 unmodified linesby_id[entry["id"]] = _merge_benchmark(by_id[entry["id"]], entry)else:by_id[entry["id"]] = entry# `preferred_metric` (seed key) -> `preferred_metric_id` (column),# validated against metrics.yaml so a typo can't silently null the# merged-view default.metrics_path = seed_path / "metrics.yaml"metric_ids: set[str] = set()if metrics_path.exists():with open(metrics_path) as f:metric_ids = {m["id"] for m in (yaml.safe_load(f) or [])}for entry in by_id.values():pm = entry.pop("preferred_metric", None)if pm is not None:if pm not in metric_ids:raise typer.BadParameter(f"benchmark {entry['id']!r}: preferred_metric {pm!r} "f"is not a canonical metric id")entry["preferred_metric_id"] = pm_check_benchmark_collisions(list(by_id.values()))return list(by_id.values())def _check_benchmark_collisions(entries: list[dict]) -> None:"""Seed-time guard: two benchmarks whose ids, display names, orglobal aliases collapse to the same normalized key (casefold +strip non-alphanumerics — stricter than collision_fold'sseparator-only key, so spaced llm-stats-mint aliases like"Vita Bench" are covered) are one entity split in two — fold themper specs/benchmark-relationships-audit.md §4. Flag-only, neverauto-folds. Groups verified genuinely distinct go inseed/benchmarks_distinct_allowlist.yaml (a list of id groups).Residual: semantic dupes with different normalized keys(mmmu-val vs mmmu-validation) are invisible to this check.Also rejects '/' in benchmark ids — reserved by the merged-viewURL scheme (single-segment merged eval ids stay collision-freewith two-segment per-source ids only while benchmark ids areslash-free)."""allow_path = seed_path / "benchmarks_distinct_allowlist.yaml"allowed: list[frozenset[str]] = []if allow_path.exists():with open(allow_path) as f:for group in yaml.safe_load(f) or []:allowed.append(frozenset(group))def _norm(s: str) -> str:# NFKD + combining-mark strip folds accent variants ("racé" vs# "race") into one key before the alphanumeric strip would# silently delete the accented char and miss the collision.# Residual: cross-script confusables (Cyrillic 'а') still evade.decomposed = unicodedata.normalize("NFKD", str(s))base = "".join(ch for ch in decomposed if not unicodedata.combining(ch))return re.sub(r"[^a-z0-9]", "", base.casefold())# Typo guard: every allowlisted id must name a real benchmark,# else a stale/misspelled allowlist entry silently stops guarding.all_ids = {str(e["id"]) for e in entries}stale = sorted({bid for grp in allowed for bid in grp} - all_ids)if stale:raise typer.BadParameter(f"benchmarks_distinct_allowlist.yaml names unknown benchmark id(s): {stale}")key_owners: dict[str, set[str]] = {}for e in entries:bid = str(e["id"])if "/" in bid:raise typer.BadParameter(f"benchmark id {bid!r} contains '/' (reserved for merged-view routing)")# id + display_name + aliases: all three become resolver# aliases at seed time (display_name is auto-promoted), so all# three can carry a dupe in.keys = {_norm(bid)}if e.get("display_name"):keys.add(_norm(e["display_name"]))keys |= {_norm(a) for a in (e.get("aliases") or []) if a}keys.discard("")for k in keys:key_owners.setdefault(k, set()).add(bid)conflicts = [sorted(ids)for ids in key_owners.values()if len(ids) > 1 and not any(ids <= grp for grp in allowed)]if conflicts:listing = "; ".join(str(g) for g in sorted(conflicts))raise typer.BadParameter(f"{len(conflicts)} separator/case-collision group(s) among benchmark "f"ids+aliases — fold them (audit spec §4) or allowlist in "f"benchmarks_distinct_allowlist.yaml: {listing}")# ------------------------------------------------------------------# Families — translate seed/families.yaml's nested {slug: {fields}}# shape into flat dicts ready for upsert. The YAML uses the slug as604 unmodified linesstore.set_table("canonical_inference_platforms", inf_plat_df)typer.echo(f" inference_platforms: {len(inf_plat_rows)}")# ------------------------------------------------------------------# Benchmark metric folds — flat dim table (no entity ids, so it skips# the seed_specs/upsert path). Entries state that `from_metric` on# `benchmark` is the preferred measurement under a generic name.# ------------------------------------------------------------------folds_path = seed_path / "metric_folds.yaml"if folds_path.exists():import pandas as pdwith open(folds_path) as f:fold_entries = yaml.safe_load(f) or []if not isinstance(fold_entries, list):raise typer.BadParameter(f"{folds_path} must be a flat list")bench_ids = {e["id"] for e in _load_benchmarks_merged()}fold_metrics_path = seed_path / "metrics.yaml"metric_ids = set()if fold_metrics_path.exists():with open(fold_metrics_path) as f:metric_ids = {m["id"] for m in (yaml.safe_load(f) or [])}seen_pairs: set[tuple[str, str]] = set()fold_rows = []for e in fold_entries:b, fm, tm = e.get("benchmark"), e.get("from_metric"), e.get("to_metric")if not (b and fm and tm):raise typer.BadParameter(f"metric_folds entry needs benchmark/from_metric/to_metric: {e!r}")if b not in bench_ids:raise typer.BadParameter(f"metric_folds: unknown benchmark {b!r}")missing = [m for m in (fm, tm) if m not in metric_ids]if missing:raise typer.BadParameter(f"metric_folds ({b}): unknown metric id(s) {missing}")if fm == tm:raise typer.BadParameter(f"metric_folds ({b}): self-fold {fm!r}")if (b, fm) in seen_pairs:raise typer.BadParameter(f"metric_folds: duplicate fold for ({b}, {fm})")seen_pairs.add((b, fm))factor = e.get("scale_factor")if factor is not None and (not isinstance(factor, (int, float)) or factor <= 0):raise typer.BadParameter(f"metric_folds ({b}): scale_factor must be a positive number, got {factor!r}")fold_rows.append({"benchmark_id": b, "from_metric_id": fm,"to_metric_id": tm, "scale_factor": factor, "note": e.get("note"),})# No chains: a fold target must not itself be folded on the same benchmark.targets = {(r["benchmark_id"], r["to_metric_id"]) for r in fold_rows}chained = sorted(targets & seen_pairs)if chained:raise typer.BadParameter(f"metric_folds: chained folds {chained}")folds_df = pd.DataFrame(fold_rows, columns=list(schemas._SCHEMAS["benchmark_metric_folds"].keys()))store.set_table("benchmark_metric_folds", folds_df)typer.echo(f" metric_folds: {len(fold_rows)}")# Derive denormalized parent-walk caches now that all canonical_models# rows are present. `model_group_id` and `lineage_origin_model_org_id`# are computed from `parents` and need the full graph to be in place.
33 unmodified lines34353637383933 unmodified lines"canonical_families","canonical_composites","canonical_metrics","eval_harnesses","canonical_inference_platforms","aliases",33 unmodified lines3435363738394033 unmodified lines"canonical_families","canonical_composites","canonical_metrics","benchmark_metric_folds","eval_harnesses","canonical_inference_platforms","aliases",
102 unmodified lines10310410510610710871 unmodified lines180181182183184185102 unmodified lines"description": pd.StringDtype(),"dataset_repo": pd.StringDtype(),"parent_benchmark_id": pd.StringDtype(),"tags": pd.StringDtype(),"metadata": pd.StringDtype(),"review_status": pd.StringDtype(),71 unmodified lines"created_at": pd.StringDtype(),"updated_at": pd.StringDtype(),},"eval_harnesses": {"id": pd.StringDtype(),"display_name": pd.StringDtype(),102 unmodified lines10310410510610710810911011171 unmodified lines183184185186187188189190191192193194195196197198199200201202203102 unmodified lines"description": pd.StringDtype(),"dataset_repo": pd.StringDtype(),"parent_benchmark_id": pd.StringDtype(),# Registry-declared default metric for the merged benchmark view# (seed key `preferred_metric`). Null → consumer fallback rules."preferred_metric_id": pd.StringDtype(),"tags": pd.StringDtype(),"metadata": pd.StringDtype(),"review_status": pd.StringDtype(),71 unmodified lines"created_at": pd.StringDtype(),"updated_at": pd.StringDtype(),},# Curated per-benchmark metric naming folds (seed/metric_folds.yaml):# `from_metric_id` on `benchmark_id` is the same measurement as# `to_metric_id` under a generic name. Naming folds ONLY — protocol# variants (cot-correct vs accuracy) never fold. Consumed by the# producer to compute `metric_id_effective` for the merged view."benchmark_metric_folds": {"benchmark_id": pd.StringDtype(),"from_metric_id": pd.StringDtype(),"to_metric_id": pd.StringDtype(),# Optional curated published-scale -> registry-scale multiplier# (e.g. 0.1 for a raw 1-10 score folding onto a [0,1] metric).# Null = scales already agree; detection-based conversion applies."scale_factor": "float64","note": pd.StringDtype(),},"eval_harnesses": {"id": pd.StringDtype(),"display_name": pd.StringDtype(),
src/eval_card_registry/cli.py+146
src/eval_card_registry/store/hf_store.py+1
src/eval_card_registry/store/schemas.py+18