j-chim commited on
Commit
17a2a1f
·
verified ·
1 Parent(s): 5c708ec

Deploy eval-card-registry service

Browse files
src/eval_card_registry/lib/seed_io.py CHANGED
@@ -29,6 +29,18 @@ WEAK_SCALAR_FIELDS = (
29
  )
30
 
31
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  def resolve_oracle_path(name: str = "hf_model_id_resolution.json") -> Path:
33
  """Absolute path to a frozen curation input (the HF oracle JSON by default).
34
 
@@ -50,7 +62,7 @@ def load_entries_from_yaml(path: Path) -> list[dict]:
50
  generated sources without a per-path existence check."""
51
  if not path.exists():
52
  return []
53
- raw = yaml.safe_load(path.read_text()) or []
54
  return (raw.get("entries") if isinstance(raw, dict) else raw) or []
55
 
56
 
@@ -63,5 +75,5 @@ def build_hf_to_dev_from_orgs_yaml(orgs_path: Path) -> dict[str, str]:
63
  org map."""
64
  from eval_entity_resolver.fold import build_curated_org_map
65
 
66
- orgs = yaml.safe_load(orgs_path.read_text()) or [] if orgs_path.exists() else []
67
  return build_curated_org_map(orgs)
 
29
  )
30
 
31
 
32
+ def safe_load_yaml(text: str):
33
+ """Parse trusted seed YAML with libyaml acceleration when available.
34
+
35
+ ``yaml.safe_load`` always selects the Python ``SafeLoader``. These source
36
+ files are read dozens of times by the refresh regression suite, so using
37
+ the API-equivalent ``CSafeLoader`` cuts minutes from cron verification.
38
+ Environments without libyaml retain the same safe Python fallback.
39
+ """
40
+ loader = getattr(yaml, "CSafeLoader", yaml.SafeLoader)
41
+ return yaml.load(text, Loader=loader)
42
+
43
+
44
  def resolve_oracle_path(name: str = "hf_model_id_resolution.json") -> Path:
45
  """Absolute path to a frozen curation input (the HF oracle JSON by default).
46
 
 
62
  generated sources without a per-path existence check."""
63
  if not path.exists():
64
  return []
65
+ raw = safe_load_yaml(path.read_text()) or []
66
  return (raw.get("entries") if isinstance(raw, dict) else raw) or []
67
 
68
 
 
75
  org map."""
76
  from eval_entity_resolver.fold import build_curated_org_map
77
 
78
+ orgs = safe_load_yaml(orgs_path.read_text()) or [] if orgs_path.exists() else []
79
  return build_curated_org_map(orgs)
src/eval_card_registry/services/resolution_service.py CHANGED
@@ -901,7 +901,6 @@ class ResolutionService:
901
 
902
  aliases_df = self.store.table("aliases")
903
  models_df = self.store.table("canonical_models")
904
- orgs_df = self.store.table("canonical_orgs")
905
 
906
  a2c: dict[str, str] = {}
907
  # PASS 1 — canonical ids FIRST. A canonical's own id is a STRONGER
@@ -924,15 +923,12 @@ class ResolutionService:
924
  if isinstance(raw, str) and "/" in raw and isinstance(cid, str):
925
  a2c.setdefault(_hsnorm(raw), cid)
926
 
927
- org_map: dict[str, str] = {}
928
- for _, row in orgs_df.iterrows():
929
- cid = row.get("id")
930
- if not isinstance(cid, str):
931
- continue
932
- org_map[_hsnorm(cid)] = cid
933
- hf_org = row.get("hf_org")
934
- if isinstance(hf_org, str):
935
- org_map[_hsnorm(hf_org)] = cid
936
 
937
  self._hub_stats_indices = (a2c, org_map)
938
  return self._hub_stats_indices
 
901
 
902
  aliases_df = self.store.table("aliases")
903
  models_df = self.store.table("canonical_models")
 
904
 
905
  a2c: dict[str, str] = {}
906
  # PASS 1 — canonical ids FIRST. A canonical's own id is a STRONGER
 
923
  if isinstance(raw, str) and "/" in raw and isinstance(cid, str):
924
  a2c.setdefault(_hsnorm(raw), cid)
925
 
926
+ # Use the same complete, store-backed org map as every other live
927
+ # resolver path. Building a reduced id/hf_org-only map here drops
928
+ # curated package aliases such as CohereLabs -> cohere and
929
+ # ibm-granite -> ibm, causing hub-stats lineage enrichment to emit
930
+ # different org ids from the bulk refresh for the very same row.
931
+ org_map = self._build_hf_to_dev()
 
 
 
932
 
933
  self._hub_stats_indices = (a2c, org_map)
934
  return self._hub_stats_indices