Skip to content

Commit

Permalink
Add the concept of last supported version
Browse files Browse the repository at this point in the history
Signed-off-by: hoangtungdinh <[email protected]>
  • Loading branch information
hoangtungdinh committed Oct 31, 2024
1 parent 24a35d5 commit 7b3da21
Show file tree
Hide file tree
Showing 5 changed files with 467 additions and 7 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,13 @@ Contributions of valid and invalid OpenDrive sample files are also welcome. New
1. Create a new Python module for each checker.
2. Specify the following global variables for the Python module

| Variable | Meaning |
| --- | --- |
| `CHECKER_ID` | The ID of the checker |
| `CHECKER_DESCRIPTION` | The description of the checker |
| `CHECKER_PRECONDITIONS` | A set of other checkers in which if any of them raise an issue, the current checker will be skipped |
| `RULE_UID` | The rule UID of the rule that the checker will check |
| Variable | Presence | Meaning |
| --- | --- | --- |
| `CHECKER_ID` | Required | The ID of the checker |
| `CHECKER_DESCRIPTION` | Required | The description of the checker |
| `CHECKER_PRECONDITIONS` | Required | A set of other checkers in which if any of them raise an issue, the current checker will be skipped |
| `RULE_UID` | Required | The rule UID of the rule that the checker will check |
| `LAST_SUPPORTED_VERSION` | Optional | The last supported version of the standard. If the input file has a version higher than the last supported version, the checker will be skipped. Do not define this variable if the checker does not have a last supported version. |

3. Implement the checker logic in the following function:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
CHECKER_DESCRIPTION = "Each connecting road shall be represented by exactly one element. A connecting road may contain as many lanes as required."
CHECKER_PRECONDITIONS = basic_preconditions.CHECKER_PRECONDITIONS
RULE_UID = "asam.net:xodr:1.7.0:junctions.connection.one_connection_element"
LAST_SUPPORTED_VERSION = "1.7.0"


def _check_junctions_connection_one_connection_element(
Expand Down
24 changes: 23 additions & 1 deletion qc_opendrive/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def execute_checker(

return

# Checker definition setting. If not satisfied then set status as SKIPPED and return
# Check definition setting. If not satisfied then set status as SKIPPED and return
if required_definition_setting:
schema_version = checker_data.schema_version

Expand All @@ -100,6 +100,28 @@ def execute_checker(

return

# Check last supported version. If not satisfied then set status as SKIPPED and return
if hasattr(checker, "LAST_SUPPORTED_VERSION"):
schema_version = checker_data.schema_version
if (
schema_version is None
or utils.compare_versions(schema_version, checker.LAST_SUPPORTED_VERSION)
> 0
):
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=checker.CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
checker.CHECKER_ID,
f"Version {schema_version} is higher than the last supported version {checker.LAST_SUPPORTED_VERSION}. Skip the check.",
)

return

# Execute checker
try:
checker.check_rule(checker_data)
Expand Down
Loading

0 comments on commit 7b3da21

Please sign in to comment.