(path: Path)
| 20 | |
| 21 | |
| 22 | def _load_structured_config(path: Path) -> dict[str, Any]: |
| 23 | text = path.read_text(encoding="utf-8") |
| 24 | if path.suffix.lower() in {".yaml", ".yml"}: |
| 25 | loaded = yaml.safe_load(text) |
| 26 | else: |
| 27 | loaded = json.loads(text) |
| 28 | if not isinstance(loaded, dict): |
| 29 | raise ValueError(f"Model config must be an object: {path}") |
| 30 | return loaded |
| 31 | |
| 32 | |
| 33 | def _extract_model_block(config: dict[str, Any]) -> dict[str, Any]: |