fix(avocet): guard discover_finetuned_models against malformed/incomplete training_info.json
This commit is contained in:
parent
36117b35c4
commit
2d795b9573
2 changed files with 11 additions and 1 deletions
|
|
@ -171,7 +171,14 @@ def discover_finetuned_models(models_dir: Path | None = None) -> list[dict]:
|
|||
info_path = sub / "training_info.json"
|
||||
if not info_path.exists():
|
||||
continue
|
||||
info = json.loads(info_path.read_text(encoding="utf-8"))
|
||||
try:
|
||||
info = json.loads(info_path.read_text(encoding="utf-8"))
|
||||
except Exception as exc:
|
||||
print(f"[discover] WARN: skipping {info_path}: {exc}", flush=True)
|
||||
continue
|
||||
if "name" not in info:
|
||||
print(f"[discover] WARN: skipping {info_path}: missing 'name' key", flush=True)
|
||||
continue
|
||||
info["model_dir"] = str(sub)
|
||||
found.append(info)
|
||||
return found
|
||||
|
|
|
|||
|
|
@ -120,6 +120,9 @@ def test_discover_finetuned_models_finds_training_info_files(tmp_path):
|
|||
names = {r["name"] for r in results}
|
||||
assert "avocet-deberta-small" in names
|
||||
assert "avocet-bge-m3" in names
|
||||
for r in results:
|
||||
assert "model_dir" in r, "discover_finetuned_models must inject model_dir key"
|
||||
assert r["model_dir"].endswith(r["name"])
|
||||
|
||||
|
||||
def test_discover_finetuned_models_returns_empty_when_no_models_dir():
|
||||
|
|
|
|||
Loading…
Reference in a new issue