Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! Refactor process test example parsing/lis…
Browse files Browse the repository at this point in the history
…ting to openeo_test_suite.lib.processes.registry
  • Loading branch information
soxofaan committed Jan 23, 2024
1 parent f700a17 commit a7ee0ae
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/openeo_test_suite/lib/processes/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,21 @@ def __init__(self, root: Optional[Path] = None):
def get_all_processes(self) -> Iterator[ProcessData]:
"""Collect all processes"""
# TODO: cache or preload this in __init__?
if not self._root.is_dir():
raise ValueError(f"Invalid process test root directory: {self._root}")
_log.info(f"Loading process definitions from {self._root}")
for path in self._root.glob("*.json5"):
try:
with path.open() as f:
data = json5.load(f)
assert data["id"] == path.stem
yield ProcessData(
process_id=data["id"],
level=data.get("level"),
tests=data.get("tests", []),
experimental=data.get("experimental", False),
path=path,
)
assert data["id"] == path.stem
yield ProcessData(
process_id=data["id"],
level=data.get("level"),
tests=data.get("tests", []),
experimental=data.get("experimental", False),
path=path,
)
except Exception as e:
# TODO: good idea to skip broken definitions? Why not just fail hard?
_log.error(f"Failed to load process data from {path}: {e!r}")

0 comments on commit a7ee0ae

Please sign in to comment.