diff --git a/README.md b/README.md index 45fef95..9af38bb 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ interacting with the configuration files and the results files from the ASAM Quality Checker Framework. With it, users can create their own Checker Bundles or Report Modules in Python. +**Disclaimer**: The current version is a release candidate. The first official release is expected to be in November. + The library features the main interfaces needed to implement a module: - Configuration: for reading and writing QC Framework [configuration files](https://github.com/asam-ev/qc-framework/blob/main/doc/manual/file_formats.md#configuration-file-xml). @@ -108,7 +110,7 @@ content: ``` -For more information regarding the configuration XSD schema you can check [here](https://github.com/asam-ev/qc-framework/blob/develop/doc/schema/config_format.xsd) +For more information regarding the configuration XSD schema you can check [here](https://github.com/asam-ev/qc-framework/blob/main/doc/schema/config_format.xsd) ### Reading checker bundle config from file @@ -242,7 +244,7 @@ content: ``` -For more information regarding the result XSD schema you can check [here](https://github.com/asam-ev/qc-framework/blob/develop/doc/schema/xqar_result_format.xsd) +For more information regarding the result XSD schema you can check [here](https://github.com/asam-ev/qc-framework/blob/main/doc/schema/xqar_result_format.xsd) ### Reading a result from checker bundle execution diff --git a/examples/json_validator/requirements.txt b/examples/json_validator/requirements.txt index 51d71e8..cd640ae 100644 --- a/examples/json_validator/requirements.txt +++ b/examples/json_validator/requirements.txt @@ -1 +1 @@ -asam-qc-baselib @ git+https://github.com/asam-ev/qc-baselib-py@develop +asam-qc-baselib @ git+https://github.com/asam-ev/qc-baselib-py@main diff --git a/examples/report_module_text/requirements.txt b/examples/report_module_text/requirements.txt index 2078d68..60e6ecc 100644 --- a/examples/report_module_text/requirements.txt +++ b/examples/report_module_text/requirements.txt @@ -1,4 +1,4 @@ -qc_baselib @ git+https://github.com/asam-ev/qc-baselib-py@develop +asam-qc-baselib @ git+https://github.com/asam-ev/qc-baselib-py@main lxml==5.2.2 numpy==2.0.0 scipy==1.14.0 diff --git a/pyproject.toml b/pyproject.toml index af563b7..0d54ef8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "asam-qc-baselib" -version = "0.1.0" +version = "1.0.0rc1" description = "Python base library for ASAM Quality Checker Framework" authors = ["Patrick Abrahão "] license = "MPL-2.0" diff --git a/qc_baselib/__init__.py b/qc_baselib/__init__.py index 35caa3a..05ce5de 100644 --- a/qc_baselib/__init__.py +++ b/qc_baselib/__init__.py @@ -3,7 +3,7 @@ # Public License, v. 2.0. If a copy of the MPL was not distributed # with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -__version__ = "0.1.0" +__version__ = "1.0.0rc1" from .configuration import Configuration as Configuration diff --git a/qc_baselib/configuration.py b/qc_baselib/configuration.py index 0bb7b2b..373ef71 100644 --- a/qc_baselib/configuration.py +++ b/qc_baselib/configuration.py @@ -3,7 +3,7 @@ # Public License, v. 2.0. If a copy of the MPL was not distributed # with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -from typing import Union, List, Dict +from typing import Union, List, Dict, Optional from .models import config, common, IssueSeverity @@ -39,14 +39,14 @@ class Configuration: ``` For more information regarding the configuration XSD schema you can check - [here](https://github.com/asam-ev/qc-framework/blob/develop/doc/schema/config_format.xsd). + [here](https://github.com/asam-ev/qc-framework/blob/main/doc/schema/config_format.xsd). """ def __init__( self, ): - self._configuration: Union[None, config.Config] = None + self._configuration: Optional[config.Config] = None def load_from_file(self, xml_file_path: str, override: bool = False) -> None: if self._configuration is not None and not override: @@ -74,7 +74,7 @@ def write_to_file(self, xml_output_file_path: str) -> None: def _get_checker_bundle( self, checker_bundle_name: str - ) -> Union[config.CheckerBundleType, None]: + ) -> Optional[config.CheckerBundleType]: if len(self._configuration.checker_bundles) == 0: return None diff --git a/qc_baselib/models/config.py b/qc_baselib/models/config.py index 0ef4397..bc60bfc 100644 --- a/qc_baselib/models/config.py +++ b/qc_baselib/models/config.py @@ -11,7 +11,7 @@ # Configuration models # Original XSD file: -# > https://github.com/asam-ev/qc-framework/blob/develop/doc/schema/config_format.xsd +# > https://github.com/asam-ev/qc-framework/blob/main/doc/schema/config_format.xsd class CheckerType(BaseXmlModel): diff --git a/qc_baselib/models/result.py b/qc_baselib/models/result.py index fd677fd..1dff5da 100644 --- a/qc_baselib/models/result.py +++ b/qc_baselib/models/result.py @@ -15,7 +15,7 @@ # Report models # Original XSD file: -# > https://github.com/asam-ev/qc-framework/blob/develop/doc/schema/xqar_report_format.xsd +# > https://github.com/asam-ev/qc-framework/blob/main/doc/schema/xqar_report_format.xsd class XMLLocationType(BaseXmlModel): diff --git a/qc_baselib/result.py b/qc_baselib/result.py index 2d8fe8f..51a2eca 100644 --- a/qc_baselib/result.py +++ b/qc_baselib/result.py @@ -7,8 +7,9 @@ from copy import deepcopy from dataclasses import dataclass -from typing import Union, List, Set +from typing import Union, List, Set, Optional from lxml import etree +from datetime import datetime from qc_baselib import Configuration from .models import IssueSeverity, StatusType, result, common @@ -48,7 +49,6 @@ class Result: result.register_checker_bundle( name="TestBundle", - build_date="2024-05-31", description="Example checker bundle", version="0.0.1", ) @@ -65,18 +65,18 @@ class Result: result.load_from_file(RESULT_FILE_PATH) - version = result.get_version() + version = result.get_result_version() ``` For more information regarding the results report XSD schema you can check - [here](https://github.com/asam-ev/qc-framework/blob/develop/doc/schema/xqar_report_format.xsd) + [here](https://github.com/asam-ev/qc-framework/blob/main/doc/schema/xqar_report_format.xsd) """ def __init__( self, ): - self._report_results: Union[None, result.CheckerResults] = None + self._report_results: Optional[result.CheckerResults] = None self._id_manager = IDManager() def load_from_file(self, xml_file_path: str, override: bool = False) -> None: @@ -251,7 +251,7 @@ def add_checker_summary( def _get_checker_bundle_without_error( self, checker_bundle_name: str - ) -> Union[None, result.CheckerBundleType]: + ) -> Optional[result.CheckerBundleType]: if self._report_results is None: raise RuntimeError( "Report not initialized. Initialize the report first by registering the version or a checker bundle." @@ -280,7 +280,7 @@ def _get_checker_bundle(self, checker_bundle_name: str) -> result.CheckerBundleT def _get_checker_without_error( self, bundle: result.CheckerBundleType, checker_id: str - ) -> Union[None, result.CheckerType]: + ) -> Optional[result.CheckerType]: checker = next( ( checker @@ -321,14 +321,18 @@ def _get_issue( def register_checker_bundle( self, - build_date: str, description: str, name: str, version: str, + build_date: Optional[str] = None, summary: str = "", ) -> None: bundle = result.CheckerBundleType( - build_date=build_date, + build_date=( + build_date + if build_date is not None + else datetime.today().strftime("%Y-%m-%d") + ), description=description, name=name, version=version, @@ -734,7 +738,7 @@ def all_checkers_completed_without_issue(self, check_id_set: Set[str]) -> bool: return result - def get_checker_status(self, checker_id: str) -> Union[None, StatusType]: + def get_checker_status(self, checker_id: str) -> Optional[StatusType]: """ Return None if the checker is not found. """ diff --git a/tests/test_result.py b/tests/test_result.py index 10e78d7..3c15890 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -2,7 +2,8 @@ import pytest from lxml import etree from pydantic_core import ValidationError -from qc_baselib.models import config, result +from datetime import datetime +from qc_baselib.models import result from qc_baselib import Result, IssueSeverity, StatusType, Configuration @@ -1503,3 +1504,17 @@ def test_create_rule_id_validation() -> None: checker_id="TestChecker", rule_uid="test.com:qc:1.0.0:", ) + + +def test_build_date() -> None: + result = Result() + + result.register_checker_bundle( + name="TestBundle", + description="Example checker bundle", + version="0.0.1", + ) + + checker_bundle_result = result.get_checker_bundle_result("TestBundle") + + assert checker_bundle_result.build_date == datetime.now().strftime("%Y-%m-%d")