Skip to content

artifact_qa_validator

Validator for the quality attribute fields of an artifact.

ArtifactQAValidator

Bases: CrossValidator

Implementation of a CrossValidator to validate an artifacts quality attributes against the custom list store.

Source code in mlte/store/validators/cross_validators/artifact_qa_validator.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class ArtifactQAValidator(CrossValidator):
    """Implementation of a CrossValidator to validate an artifacts quality attributes against the custom list store."""

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

    def validate(self, new_artifact: ArtifactModel) -> None:
        with ManagedCustomListSession(
            self.custom_list_store.session()
        ) as session:
            if new_artifact.header.type == ArtifactType.NEGOTIATION_CARD:
                card = typing.cast(NegotiationCardModel, new_artifact.body)
                for requirement in card.system_requirements:
                    if requirement.quality != "":
                        try:
                            session.custom_list_entry_mapper.read(
                                requirement.quality,
                                CustomListName.QUALITY_ATTRIBUTES,
                            )
                        except ErrorNotFound:
                            raise RuntimeError(
                                f"Artifact quality attribute validation failure. Quality attribute: {requirement.quality} not found. For artifact {new_artifact.header.identifier}."
                            )

__init__(custom_list_store)

Initialize a ArtifactQAValidator 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/artifact_qa_validator.py
18
19
20
21
22
23
24
25
26
def __init__(
    self,
    custom_list_store: CustomListStore,
):
    """
    Initialize a ArtifactQAValidator instance.
    :param custom_list_store: Custom list store store to use for validation.
    """
    self.custom_list_store = custom_list_store