Skip to content

sift_client.util.metadata

FUNCTION DESCRIPTION
metadata_dict_to_proto

Converts metadata dictionary into a list of MetadataValue objects.

metadata_proto_to_dict

Converts a list of MetadataValue objects into a dictionary.

metadata_dict_to_proto

metadata_dict_to_proto(
    _metadata: dict[str, str | float | bool],
) -> list[MetadataValue]

Converts metadata dictionary into a list of MetadataValue objects.

PARAMETER DESCRIPTION
_metadata

Dictionary of metadata key-value pairs.

TYPE: dict[str, str | float | bool]

RETURNS DESCRIPTION
list[MetadataValue]

List of MetadataValue objects.

metadata_proto_to_dict

metadata_proto_to_dict(
    metadata: list[MetadataValue],
) -> dict[str, str | float | bool]

Converts a list of MetadataValue objects into a dictionary.

A key may appear multiple times when it holds multiple values (multi-value metadata). The dictionary keeps the first value of each key -- the API returns values in canonical order, so this matches the value every other single-value context (e.g. backend flattening) uses.

PARAMETER DESCRIPTION
metadata

List of MetadataValue objects.

TYPE: list[MetadataValue]

RETURNS DESCRIPTION
dict[str, str | float | bool]

Dictionary of metadata key-value pairs (first value per key).