Back to report index

Step 7b visualizationoverlays 28070a6: AI3D-379 Use shared load_json_overrides for the override file

Miroslav Simko <ms@iolabs.ch> 2026-09-02T11:50:12+02:00

Commit #48 ยท 2 snippets

 .../_config.py                                     | 27 ++++------------------
 1 file changed, 4 insertions(+), 23 deletions(-)
Importance #1: src/iolabs_point_cloud_visualization_overlays/_config.py @@ -15,9 +15,8 @@
15"""15"""
1616
17from __future__ import annotations17from __future__ import annotations
1818
19import json
20import logging19import logging
21from collections.abc import Mapping20from collections.abc import Mapping
22from pathlib import Path21from pathlib import Path
23from typing import Annotated, Any, Literal, TypeAlias22from typing import Annotated, Any, Literal, TypeAlias
Importance #2: src/iolabs_point_cloud_visualization_overlays/_config.py @@ -163,32 +162,14 @@
163 return self162 return self
164163
165164
166def _load_json_overrides(config_path: str | Path | None) -> dict[str, Any]:165def _load_json_overrides(config_path: str | Path | None) -> dict[str, Any]:
167 """Read a JSON override file, or return an empty mapping when there is none.166 """Read a JSON override file, or return an empty mapping when there is none."""
168
169 Local stand-in for the shared ``config_loader.load_json_overrides`` helper;
170 drop it once the shared layer exports one.
171
172 Raises:
173 XmlTopdownOverlayConfigError: The file is not valid JSON, or does not
174 hold a JSON object.
175 """
176 if config_path is None:167 if config_path is None:
177 return {}168 return {}
178 path = Path(config_path)169 return config_loader.load_json_overrides(
179 try:170 config_path, error_cls=XmlTopdownOverlayConfigError
180 with path.open(encoding="utf-8") as handle:171 )
181 raw = json.load(handle)
182 except json.JSONDecodeError as exc:
183 raise XmlTopdownOverlayConfigError(
184 f"Invalid JSON in config file {path}: {exc}"
185 ) from exc
186 if not isinstance(raw, dict):
187 raise XmlTopdownOverlayConfigError(
188 f"Config file {path} must hold a JSON object, got {type(raw).__name__}"
189 )
190 return raw
191172
192173
193def _load_model(174def _load_model(
194 *,175 *,