Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add summary to the result #60

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ def check_rule(checker_data: models.CheckerData) -> None:

logging.debug(f"current_transition_time: {current_transition_time}")
if not utils.is_xsd_double(current_transition_time):
logging.error(
f"Cannot convert '{current_transition_time}' to double as it does not match xsd:double pattern. Skipping check..."
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"Cannot convert '{current_transition_time}' to double as it does not match xsd:double pattern. Skip the check.",
)

return

current_numeric_value = utils.to_float(current_transition_time)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,18 @@ def check_rule(checker_data: models.CheckerData) -> None:
current_duration = current_duration_param_value

if not utils.is_xsd_double(current_duration):
logging.error(
f"Cannot convert '{current_duration}' to double as it does not match xsd:double pattern. Skipping check..."
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"Cannot convert '{current_duration}' to double as it does not match xsd:double pattern. Skip the check.",
)

return

current_numeric_value = utils.to_float(current_duration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def check_rule(checker_data: models.CheckerData) -> None:
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find Catalog nodes in provided XOSC file. Skip the check.",
)

return

logging.debug(f"catalogs_node : {catalogs_node}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ def check_rule(checker_data: models.CheckerData) -> None:

entities_node = root.find("Entities")
if entities_node is None:
logging.error("Cannot find Entities node in provided XOSC file. Skipping check")

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find Entities node in provided XOSC file. Skip the check.",
)

return

defined_entities = set()
Expand All @@ -51,15 +56,18 @@ def check_rule(checker_data: models.CheckerData) -> None:
logging.debug(f"Defined entities : {defined_entities}")
storyboard_node = root.find("Storyboard")
if storyboard_node is None:
logging.error(
"Cannot find Storyboard node in provided XOSC file. Skipping check"
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find Storyboard node in provided XOSC file. Skip the check.",
)

return

nodes_with_entity_ref = storyboard_node.xpath(".//*[@entityRef]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,35 @@ def check_rule(checker_data: models.CheckerData) -> None:
root = checker_data.input_file_xml_root

if checker_data.xodr_root is None:
logging.error(f" - Cannot read xodr file. Abort")
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot read xodr file. Skip the check.",
)

return

xodr_signal_list = checker_data.xodr_root.findall(".//signal")

if xodr_signal_list is None:
logging.error(f" - Cannot read signals from xodr file. Abort")
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot read signals from xodr file. Skip the check.",
)

return

xodr_signal_ids = set()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,34 @@ def check_rule(checker_data: models.CheckerData) -> None:

storyboard_node = root.find("Storyboard")
if storyboard_node is None:
logging.error(
"Cannot find Storyboard node in provided XOSC file. Skipping check"
)
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find Storyboard node in the provided XOSC file. Skip the check.",
)
return

xpath_expr = "|".join([f"//{node}" for node in STORYBOARD_ELEMENTS])
storyboard_elements = storyboard_node.xpath(xpath_expr)
if storyboard_elements is None:
logging.error(
"Cannot find Storyboard elements node in provided XOSC file. Skipping check"
)
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find Storyboard elements node in the provided XOSC file. Skip the check.",
)

return

storyboard_element_type = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,35 @@ def check_rule(checker_data: models.CheckerData) -> None:

road_network = root.find("RoadNetwork")
if road_network is None:
logging.error(
"Cannot find RoadNetwork node in provided XOSC file. Skipping check"
)
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find RoadNetwork node. Skip the check.",
)

return

# ts = traffic signal
ts_controllers = road_network.findall(".//TrafficSignalController")
if ts_controllers is None:
logging.error(
"Cannot find TrafficSignalController nodes in RoadNetwork of provided XOSC file. Skipping check"
)
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find TrafficSignalController nodes in RoadNetwork. Skip the check.",
)

return

ts_controller_names = set()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ def check_rule(checker_data: models.CheckerData) -> None:

storyboard_node = root.find("Storyboard")
if storyboard_node is None:
logging.error(
"Cannot find Storyboard node in provided XOSC file. Skipping check"
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find Storyboard node. Skip the check.",
)

return

nodes_with_variable_ref = storyboard_node.xpath(".//*[@variableRef]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ def check_rule(checker_data: models.CheckerData) -> None:

maneuver_groups = root.findall(".//ManeuverGroup")
if maneuver_groups is None:
logging.error(
"Cannot find ManeuverGroup node in provided XOSC file. Skipping check"
)
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find ManeuverGroup node. Skip the check.",
)
return

for maneuver_group in maneuver_groups:
Expand All @@ -56,15 +59,18 @@ def check_rule(checker_data: models.CheckerData) -> None:
entity_refs = maneuver_group.findall(".//EntityRef")

if private_actions is None or entity_refs is None:
logging.error(
"Cannot find PrivateAction or EntityRef node in provided XOSC file. Skipping check"
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"Cannot find PrivateAction or EntityRef node. Skip the check.",
)

return

has_private_action = len(private_actions) > 0
Expand Down
10 changes: 6 additions & 4 deletions qc_openscenario/checks/schema_checker/valid_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,18 @@ def check_rule(checker_data: models.CheckerData) -> None:
xsd_file = schema_files.SCHEMA_FILES.get(schema_version)

if xsd_file is None:
logging.info(
f"- Schema file for version {schema_version} does not exist. Skipping check"
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"- Schema file for version {schema_version} does not exist. Skip the check.",
)

return

xsd_file_path = str(
Expand Down
21 changes: 19 additions & 2 deletions qc_openscenario/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def execute_checker(
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
checker.CHECKER_ID,
"Preconditions are not satisfied. Skip the check.",
)

return

# Checker definition setting. If not satisfied then set status as SKIPPED and return
Expand All @@ -84,6 +90,12 @@ def execute_checker(
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
checker.CHECKER_ID,
f"Version {schema_version} is lower than definition setting {definition_setting}. Skip the check.",
)

return

# Execute checker
Expand All @@ -100,14 +112,18 @@ def execute_checker(
checker_id=checker.CHECKER_ID,
status=StatusType.COMPLETED,
)
except Exception:
except Exception as e:
# If any exception occurs during the check, set the status as ERROR
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=checker.CHECKER_ID,
status=StatusType.ERROR,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME, checker.CHECKER_ID, f"Error: {str(e)}."
)


def run_checks(config: Configuration, result: Result) -> None:
checker_data = models.CheckerData(
Expand Down Expand Up @@ -236,7 +252,8 @@ def main():
result.write_to_file(
config.get_checker_bundle_param(
checker_bundle_name=constants.BUNDLE_NAME, param_name="resultFile"
)
),
generate_summary=True,
)

if args.generate_markdown:
Expand Down