Skip to content

Commit

Permalink
Merge pull request #44 from asam-ev/2024-10-01
Browse files Browse the repository at this point in the history
For CCB Review: Prepare for the release candidate v1.0.0-rc.1
  • Loading branch information
andreaskern74 authored Oct 7, 2024
2 parents c9e5493 + cce6dc9 commit d4d87ed
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 23 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -108,7 +110,7 @@ content:
</Config>
```

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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/json_validator/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion examples/report_module_text/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MPL-2.0"
Expand Down
2 changes: 1 addition & 1 deletion qc_baselib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions qc_baselib/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion qc_baselib/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion qc_baselib/models/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
24 changes: 14 additions & 10 deletions qc_baselib/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
)
Expand All @@ -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:
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
"""
Expand Down
17 changes: 16 additions & 1 deletion tests/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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")

0 comments on commit d4d87ed

Please sign in to comment.