mirror of
https://github.com/block/buzz.git
synced 2026-11-07 01:41:06 +00:00
fix(catalog): route all model rows through the shared label resolver
Two discovered-row callsites still formatted labels inline, so a known Databricks endpoint returned by discovery without a name rendered as its raw ID instead of the curated registry name — the exact inconsistency the shared resolver exists to prevent. The generator also trusted the models.dev payload shape: a non-object model value silently emitted `id -> id`, baking a wrong label into both committed artifacts where no test could distinguish it from a genuine pass-through. Validation now rejects that instead. Registry parity is pinned across the whole table rather than five sampled rows, so a half-committed regenerate cannot pass. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
parent
38558504ca
commit
be7d66ff3b
@@ -144,6 +144,59 @@ def write_ts(entries: list[tuple[str, str]]) -> None:
|
||||
print(f"Wrote {TS_OUT.relative_to(REPO_ROOT)}")
|
||||
|
||||
|
||||
def extract_entries(data: object) -> list[tuple[str, str]]:
|
||||
"""Pull sorted (id, name) pairs out of the models.dev payload.
|
||||
|
||||
Every container and leaf shape is checked explicitly so an upstream
|
||||
restructure fails with an actionable message instead of a bare KeyError
|
||||
or — worse — a silently degraded table where a malformed entry emits
|
||||
`id -> id` and permanently masks the real curated name.
|
||||
"""
|
||||
if not isinstance(data, dict):
|
||||
raise RuntimeError(
|
||||
f"Unexpected models.dev shape: root must be an object, got {type(data).__name__}"
|
||||
)
|
||||
provider = data.get("databricks")
|
||||
if provider is None:
|
||||
raise RuntimeError("Unexpected models.dev shape: missing data['databricks']")
|
||||
if not isinstance(provider, dict):
|
||||
raise RuntimeError(
|
||||
"Unexpected models.dev shape: data['databricks'] must be an object, "
|
||||
f"got {type(provider).__name__}"
|
||||
)
|
||||
models = provider.get("models")
|
||||
if models is None:
|
||||
raise RuntimeError(
|
||||
"Unexpected models.dev shape: missing data['databricks']['models']"
|
||||
)
|
||||
if not isinstance(models, dict):
|
||||
raise RuntimeError(
|
||||
"Unexpected models.dev shape: data['databricks']['models'] must be an "
|
||||
f"object, got {type(models).__name__}"
|
||||
)
|
||||
if not models:
|
||||
raise RuntimeError(
|
||||
"Unexpected models.dev shape: data['databricks']['models'] is empty"
|
||||
)
|
||||
|
||||
entries: list[tuple[str, str]] = []
|
||||
for model_id, model in models.items():
|
||||
where = f"data['databricks']['models'][{model_id!r}]"
|
||||
if not isinstance(model, dict):
|
||||
raise RuntimeError(
|
||||
f"Unexpected models.dev shape: {where} must be an object, "
|
||||
f"got {type(model).__name__}"
|
||||
)
|
||||
name = model.get("name")
|
||||
if not isinstance(name, str):
|
||||
raise RuntimeError(
|
||||
f"Unexpected models.dev shape: {where}['name'] must be a string, "
|
||||
f"got {type(name).__name__}"
|
||||
)
|
||||
entries.append((model_id, name))
|
||||
return sorted(entries)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
raw = fetch(URL)
|
||||
try:
|
||||
@@ -151,16 +204,7 @@ def main() -> None:
|
||||
except json.JSONDecodeError as e:
|
||||
raise RuntimeError(f"models.dev response is not valid JSON: {e}") from e
|
||||
|
||||
if "databricks" not in data or "models" not in data["databricks"]:
|
||||
raise RuntimeError(
|
||||
"Unexpected models.dev shape: missing data['databricks']['models']"
|
||||
)
|
||||
|
||||
models: dict = data["databricks"]["models"]
|
||||
raw_entries = sorted(
|
||||
(k, v["name"] if isinstance(v, dict) else k) for k, v in models.items()
|
||||
)
|
||||
entries = validate_entries(raw_entries)
|
||||
entries = validate_entries(extract_entries(data))
|
||||
|
||||
write_rust(entries)
|
||||
write_ts(entries)
|
||||
|
||||
Reference in New Issue
Block a user