Metadata
zenml.metadata
special
Initialization of ZenML metadata.
ZenML metadata is any additional, dynamic information that is associated with your pipeline runs and artifacts at runtime.
metadata_types
Custom types that can be used as metadata of ZenML artifacts.
DType (str)
Special string class to indicate a data type.
Source code in zenml/metadata/metadata_types.py
class DType(str):
"""Special string class to indicate a data type."""
MetadataTypeEnum (StrEnum)
String Enum of all possible types that metadata can have.
Source code in zenml/metadata/metadata_types.py
class MetadataTypeEnum(StrEnum):
"""String Enum of all possible types that metadata can have."""
STRING = "str"
INT = "int"
FLOAT = "float"
BOOL = "bool"
LIST = "list"
DICT = "dict"
TUPLE = "tuple"
SET = "set"
URI = "Uri"
PATH = "Path"
DTYPE = "DType"
STORAGE_SIZE = "StorageSize"
Path (str)
Special string class to indicate a path.
Source code in zenml/metadata/metadata_types.py
class Path(str):
"""Special string class to indicate a path."""
StorageSize (int)
Special int class to indicate the storage size in number of bytes.
Source code in zenml/metadata/metadata_types.py
class StorageSize(int):
"""Special int class to indicate the storage size in number of bytes."""
Uri (str)
Special string class to indicate a URI.
Source code in zenml/metadata/metadata_types.py
class Uri(str):
"""Special string class to indicate a URI."""
cast_to_metadata_type(value, type_)
Cast an object to a metadata type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
object |
The object to cast. |
required |
type_ |
MetadataTypeEnum |
The metadata type to cast to. |
required |
Returns:
Type | Description |
---|---|
Union[str, int, float, bool, Dict[Any, Any], List[Any], Set[Any], Tuple[Any, ...], zenml.metadata.metadata_types.Uri, zenml.metadata.metadata_types.Path, zenml.metadata.metadata_types.DType, zenml.metadata.metadata_types.StorageSize] |
The value cast to the given metadata type. |
Source code in zenml/metadata/metadata_types.py
def cast_to_metadata_type(
value: object,
type_: MetadataTypeEnum,
) -> MetadataType:
"""Cast an object to a metadata type.
Args:
value: The object to cast.
type_: The metadata type to cast to.
Returns:
The value cast to the given metadata type.
"""
metadata_type = metadata_enum_to_type_mapping[type_]
typed_value = metadata_type(value)
return typed_value # type: ignore[no-any-return]
get_metadata_type(object_)
Get the metadata type enum for a given object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
object_ |
object |
The object to get the metadata type for. |
required |
Returns:
Type | Description |
---|---|
MetadataTypeEnum |
The corresponding metadata type enum. |
Exceptions:
Type | Description |
---|---|
ValueError |
If the metadata type is not supported. |
Source code in zenml/metadata/metadata_types.py
def get_metadata_type(
object_: object,
) -> MetadataTypeEnum:
"""Get the metadata type enum for a given object.
Args:
object_: The object to get the metadata type for.
Returns:
The corresponding metadata type enum.
Raises:
ValueError: If the metadata type is not supported.
"""
metadata_type = type(object_)
if metadata_type in metadata_type_to_enum_mapping:
return metadata_type_to_enum_mapping[metadata_type]
raise ValueError(f"Metadata type {metadata_type} is not supported.")