diff --git a/raillabel_providerkit/validation/issue.py b/raillabel_providerkit/validation/issue.py index 5c490fd..c654ee6 100644 --- a/raillabel_providerkit/validation/issue.py +++ b/raillabel_providerkit/validation/issue.py @@ -3,6 +3,7 @@ from dataclasses import dataclass from enum import Enum +from uuid import UUID class IssueType(Enum): @@ -17,9 +18,9 @@ class IssueType(Enum): class IssueIdentifiers: """Information for locating an issue.""" - annotation: str | None = None - frame: str | None = None - object: str | None = None + annotation: UUID | None = None + frame: int | None = None + object: UUID | None = None sensor: str | None = None diff --git a/raillabel_providerkit/validation/validate_empty_frames/validate_empty_frames.py b/raillabel_providerkit/validation/validate_empty_frames/validate_empty_frames.py index c7b70bf..2ba798e 100644 --- a/raillabel_providerkit/validation/validate_empty_frames/validate_empty_frames.py +++ b/raillabel_providerkit/validation/validate_empty_frames/validate_empty_frames.py @@ -5,27 +5,25 @@ import raillabel +from raillabel_providerkit.validation import Issue, IssueIdentifiers, IssueType -def validate_empty_frames(scene: raillabel.Scene) -> list[str]: - """Validate whether all frames of a scene have at least one annotation. - - Parameters - ---------- - scene : raillabel.Scene - Scene, that should be validated. - Returns - ------- - list[str] - list of all empty frame errors in the scene. If an empty list is returned, then there are no - errors present. +def validate_empty_frames(scene: raillabel.Scene) -> list[Issue]: + """Validate whether all frames of a scene have at least one annotation. + If an empty list is returned, then there are no errors present. """ - errors: list[str] = [] + errors = [] for frame_uid, frame in scene.frames.items(): if _is_frame_empty(frame): - errors.append("Frame " + str(frame_uid) + " has no annotations!") + errors.append( + Issue( + type=IssueType.EMPTY_FRAMES, + reason="This frame has no annotations.", + identifiers=IssueIdentifiers(frame=frame_uid), + ) + ) return errors diff --git a/tests/test_raillabel_providerkit/validation/validate_empty_frame/test_validate_empty_frames.py b/tests/test_raillabel_providerkit/validation/validate_empty_frame/test_validate_empty_frames.py index 7f1eea1..d4c5763 100644 --- a/tests/test_raillabel_providerkit/validation/validate_empty_frame/test_validate_empty_frames.py +++ b/tests/test_raillabel_providerkit/validation/validate_empty_frame/test_validate_empty_frames.py @@ -7,6 +7,7 @@ _is_frame_empty, validate_empty_frames, ) +from raillabel_providerkit.validation import Issue, IssueIdentifiers, IssueType def test_is_frame_empty__true(empty_frame): @@ -59,10 +60,12 @@ def test_validate_empty_frames__error_message_contains_indentifying_info(empty_f 0: empty_frame, } - error_message = validate_empty_frames(scene)[0].lower() - assert "frame" in error_message - assert "0" in error_message - assert "empty" in error_message or "no annotations" in error_message + actual = validate_empty_frames(scene)[0] + assert actual == Issue( + type=IssueType.EMPTY_FRAMES, + reason="This frame has no annotations.", + identifiers=IssueIdentifiers(frame=0), + ) if __name__ == "__main__":