Skip to content

metadata

mlte/evidence/metadata.py

EvidenceMetadata class definition.

EvidenceMetadata

Bases: BaseModel

A simple wrapper for evidence metadata.

Source code in mlte/evidence/metadata.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class EvidenceMetadata(BaseModel):
    """A simple wrapper for evidence metadata."""

    measurement_type: str
    """The name of the measurement class type."""

    identifier: Identifier
    """The identifier for the evidence."""

    info: Optional[str] = None
    """Additional unstructured information to be stored with the metadata."""

    def get_id(self) -> str:
        """Returns the id as a string."""
        return str(self.identifier)

    def __str__(self) -> str:
        """Return a string representation of a EvidenceMetadata."""
        representation = f"{self.measurement_type}-{self.identifier}"
        if self.info is not None:
            representation += f"-{self.info}"
        return representation

    def __eq__(self, other: object) -> bool:
        """Compare instances for equality."""
        if not isinstance(other, EvidenceMetadata):
            return False
        return super().__eq__(other)

identifier instance-attribute

The identifier for the evidence.

info = None class-attribute instance-attribute

Additional unstructured information to be stored with the metadata.

measurement_type instance-attribute

The name of the measurement class type.

__eq__(other)

Compare instances for equality.

Source code in mlte/evidence/metadata.py
59
60
61
62
63
def __eq__(self, other: object) -> bool:
    """Compare instances for equality."""
    if not isinstance(other, EvidenceMetadata):
        return False
    return super().__eq__(other)

__str__()

Return a string representation of a EvidenceMetadata.

Source code in mlte/evidence/metadata.py
52
53
54
55
56
57
def __str__(self) -> str:
    """Return a string representation of a EvidenceMetadata."""
    representation = f"{self.measurement_type}-{self.identifier}"
    if self.info is not None:
        representation += f"-{self.info}"
    return representation

get_id()

Returns the id as a string.

Source code in mlte/evidence/metadata.py
48
49
50
def get_id(self) -> str:
    """Returns the id as a string."""
    return str(self.identifier)

Identifier

Bases: BaseModel

Identifier is a simple class that standardizes the manner in which Measurements, Values, and Results are uniquely identified throughout their lifetimes.

Source code in mlte/evidence/metadata.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Identifier(BaseModel):
    """
    Identifier is a simple class that standardizes
    the manner in which Measurements, Values, and
    Results are uniquely identified throughout
    their lifetimes.
    """

    name: str
    """The name of the object."""

    def __eq__(self, other: object) -> bool:
        """Compare two Identifier instances for equality."""
        if not isinstance(other, Identifier):
            return False
        return super().__eq__(other)

    def __str__(self) -> str:
        """Return a string representation of Identifier."""
        return f"{self.name}"

name instance-attribute

The name of the object.

__eq__(other)

Compare two Identifier instances for equality.

Source code in mlte/evidence/metadata.py
25
26
27
28
29
def __eq__(self, other: object) -> bool:
    """Compare two Identifier instances for equality."""
    if not isinstance(other, Identifier):
        return False
    return super().__eq__(other)

__str__()

Return a string representation of Identifier.

Source code in mlte/evidence/metadata.py
31
32
33
def __str__(self) -> str:
    """Return a string representation of Identifier."""
    return f"{self.name}"