Skip to content

catalog_qa_validator

Validator for the quality attribute field of a catalog entry.

CatalogQAValidator

Bases: CrossValidator

Implementation of CrossValidator to validate a catalog entry QA ßagainst custom list store.

Source code in mlte/store/validators/cross_validators/catalog_qa_validator.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class CatalogQAValidator(CrossValidator):
    """Implementation of CrossValidator to validate a catalog entry QA ßagainst custom list store."""

    def __init__(
        self,
        custom_list_store: CustomListStore,
    ):
        """
        Initialize a CatalogQAValidator instance.
        :param custom_list_store: Custom list store store to use for validation.
        """
        self.custom_list_store = custom_list_store

    def validate(self, new_entry: CatalogEntry) -> None:
        if new_entry.quality_attribute != "":
            with ManagedCustomListSession(
                self.custom_list_store.session()
            ) as session:
                try:
                    session.custom_list_entry_mapper.read(
                        new_entry.quality_attribute,
                        CustomListName.QUALITY_ATTRIBUTES,
                    )
                except ErrorNotFound:
                    raise RuntimeError(
                        f"Catalog entry quality attribute validation failure. Quality attribute: {new_entry.quality_attribute} not found. For catalog entry {new_entry.header.identifier}."
                    )

__init__(custom_list_store)

Initialize a CatalogQAValidator instance.

Parameters:

Name Type Description Default
custom_list_store CustomListStore

Custom list store store to use for validation.

required
Source code in mlte/store/validators/cross_validators/catalog_qa_validator.py
14
15
16
17
18
19
20
21
22
def __init__(
    self,
    custom_list_store: CustomListStore,
):
    """
    Initialize a CatalogQAValidator instance.
    :param custom_list_store: Custom list store store to use for validation.
    """
    self.custom_list_store = custom_list_store