base
mlte/value/base.py
The base class for MLTE value extensions.
NOTE: The Value
implementation in this module (base
) should not be
confused with the Value
implementation in the artifact
module.
The Value
implementation in artifact
is a proper MLTE artifact, it
should be used for all "internal" types part of the MLTE value system.
The Value
implementation in this module is meant to be extended by users
of MLTE to enrich the value system with their own value types; it provides
the link between the statically-typed MLTE value system and dynamic extensions.
ValueBase
Bases: Value
The base class for MLTE value extensions.
Source code in mlte/value/base.py
28 29 30 31 32 33 34 35 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
__str__()
Return a string representation, by default serializing it.
Source code in mlte/value/base.py
88 89 90 |
|
__subclasshook__(subclass)
classmethod
Define the interface for all Value subclasses.
Source code in mlte/value/base.py
31 32 33 34 |
|
deserialize(metadata, data)
abstractmethod
classmethod
Deserialize a Value instance from serialized representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata
|
EvidenceMetadata
|
Evidence metadata associated with the value |
required |
data
|
Dict[str, Any]
|
The serialized representation |
required |
Returns:
Type | Description |
---|---|
ValueBase
|
The deserialized value |
Source code in mlte/value/base.py
44 45 46 47 48 49 50 51 52 53 54 55 |
|
from_model(model)
classmethod
Deserialize a value from its corresponding model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
ArtifactModel
|
The artifact model |
required |
Returns:
Type | Description |
---|---|
ValueBase
|
The deserialized artifact |
Source code in mlte/value/base.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
serialize()
abstractmethod
Serialize the value to a JSON-compatible dictionary.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The dictionary representation |
Source code in mlte/value/base.py
36 37 38 39 40 41 42 |
|
to_model()
Serialize a value to its corresponding model.
Returns:
Type | Description |
---|---|
ArtifactModel
|
The artifact model |
Source code in mlte/value/base.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|