-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright DB Netz AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import typing as t | ||
from pathlib import Path | ||
|
||
import raillabel | ||
|
||
from . import validate_onthology | ||
|
||
|
||
def validate(scene: raillabel.Scene, onthology: t.Union[dict, Path]) -> t.List[str]: | ||
"""Validate a scene based on the Deutsche Bahn Requirements. | ||
Parameters | ||
---------- | ||
scene : raillabel.Scene | ||
The scene containing the annotations. | ||
onthology : dict or Path | ||
Onthology YAML-data or file containing a information about all classes and their | ||
attributes. The onthology must adhere to the onthology_schema. If a path is provided, the | ||
file is loaded as a YAML. | ||
Returns | ||
------- | ||
list[str] | ||
list of all requirement errors in the scene. If an empty list is returned, then there are | ||
no errors present and the scene is valid. | ||
""" | ||
|
||
errors = [] | ||
|
||
errors += validate_onthology(scene, onthology) | ||
|
||
return errors |
27 changes: 27 additions & 0 deletions
27
tests/test_raillabel_providerkit/validation/test_validate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright DB Netz AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import sys | ||
import typing as t | ||
from pathlib import Path | ||
from uuid import uuid4 | ||
|
||
import pytest | ||
import raillabel | ||
|
||
sys.path.append(str(Path(__file__).parent.parent.parent.parent.parent)) | ||
from raillabel_providerkit import validate | ||
|
||
# == Tests ============================ | ||
|
||
def test_no_errors(demo_onthology, valid_onthology_scene): | ||
assert validate(valid_onthology_scene, demo_onthology) == [] | ||
|
||
def test_onthology_errors(demo_onthology, invalid_onthology_scene): | ||
assert len(validate(invalid_onthology_scene, demo_onthology)) == 1 | ||
|
||
|
||
if __name__ == "__main__": | ||
os.system("clear") | ||
pytest.main([__file__, "--disable-pytest-warnings", "--cache-clear", "-v"]) |