Skip to content

model

Model implementation for MLTE artifacts.

ArtifactHeaderModel

Bases: BaseModel

The ArtifactHeaderModel contains the common metadata for all artifacts.

Source code in mlte/artifact/model.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class ArtifactHeaderModel(BaseModel):
    """The ArtifactHeaderModel contains the common metadata for all artifacts."""

    identifier: str
    """The unique identifier for the artifact."""

    type: ArtifactType
    """The type identfier for the artifact."""

    timestamp: Optional[int] = -1
    """The timestamp of creation of this artifact, as Unix time."""

    creator: Optional[str] = None
    """The user that created this artifact."""

    level: ArtifactLevel = ArtifactLevel.VERSION
    """The level this artifact will exist at (model or version)."""

    model_config = ConfigDict(use_enum_values=True)

creator = None class-attribute instance-attribute

The user that created this artifact.

identifier instance-attribute

The unique identifier for the artifact.

level = ArtifactLevel.VERSION class-attribute instance-attribute

The level this artifact will exist at (model or version).

timestamp = -1 class-attribute instance-attribute

The timestamp of creation of this artifact, as Unix time.

type instance-attribute

The type identfier for the artifact.

ArtifactLevel

Bases: StrEnum

Level the artifact will exist at (model or version).

Source code in mlte/artifact/model.py
20
21
22
23
24
25
26
27
class ArtifactLevel(StrEnum):
    """Level the artifact will exist at (model or version)."""

    MODEL = "model"
    """Store this artifact at the model level."""

    VERSION = "version"
    """Store this artifact at the version level."""

MODEL = 'model' class-attribute instance-attribute

Store this artifact at the model level.

VERSION = 'version' class-attribute instance-attribute

Store this artifact at the version level.

ArtifactModel

Bases: Filterable

The base model for all MLTE artifacts.

Source code in mlte/artifact/model.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class ArtifactModel(Filterable):
    """The base model for all MLTE artifacts."""

    header: ArtifactHeaderModel
    """The artifact header."""

    body: Union[
        NegotiationCardModel,
        EvidenceModel,
        TestSuiteModel,
        TestResultsModel,
        ReportModel,
    ] = Field(..., discriminator="artifact_type")
    """The artifact body."""

    def get_identifier(self) -> str:
        return self.header.identifier

    def get_type(self) -> ArtifactType:
        return self.header.type

    @model_validator(mode="after")
    def post_validation_caller(self) -> ArtifactModel:
        """Called after validation, lets submodel do any needed post-processing."""
        self.body.post_validation_hook(self.header.identifier)
        return self

body = Field(..., discriminator='artifact_type') class-attribute instance-attribute

The artifact body.

header instance-attribute

The artifact header.

post_validation_caller()

Called after validation, lets submodel do any needed post-processing.

Source code in mlte/artifact/model.py
72
73
74
75
76
@model_validator(mode="after")
def post_validation_caller(self) -> ArtifactModel:
    """Called after validation, lets submodel do any needed post-processing."""
    self.body.post_validation_hook(self.header.identifier)
    return self