Documentation Index
Fetch the complete documentation index at: https://docs.encord.com/llms.txt
Use this file to discover all available pages before exploring further.
class MetadataSchemaError(RuntimeError)
Raised when an invariant is violated when mutating metadata schemas
A class to manage the metadata schema for an organization.
Methods:
save() -> None: Saves the metadata schema to the backend if it has been modified.
save
Saves the metadata schema to the backend if changes have been made.
add_embedding
def add_embedding(k: str, *, size: int) -> None
Adds a new embedding to the metadata schema.
Arguments:
k : str: The key under which the embedding will be stored in the schema.
size : int: The size of the embedding.
Raises:
MetadataSchemaError - If the key k is already defined in the schema.
add_geospatial
def add_geospatial(k: str) -> None
Adds a new geospatial type to the metadata schema.
Arguments:
k : str: The key under which the geospatial coordinates will be stored in the schema.
Raises:
MetadataSchemaError - If the key k is already defined in the schema.
add_enum
def add_enum(k: str, *, values: Sequence[str]) -> None
Adds a new enum to the metadata schema.
Arguments:
k : str: The key under which the enum will be stored in the schema.
values : Sequence[str]: The set of values for the enum (min 1, max 256).
Raises:
MetadataSchemaError - If the key k is already defined in the schema.
add_enum_options
def add_enum_options(k: str, *, values: Sequence[str]) -> None
Adds extra valid enum values to an existing enum schema.
Arguments:
k : str: The key referencing the enum.
values : Sequence[str]: The set of new values to add to the enum (min 1, max 256).
Raises:
MetadataSchemaError - If the key k is not defined in the schema or is not an enum.
add_scalar
def add_scalar(
k: str, *, data_type: Union[
Literal["boolean", "datetime", "number", "uuid", "varchar", "text",
"string", "long_string"],
MetadataSchemaScalarType,
]
) -> None
Sets a simple metadata type for a given key in the schema.
Arguments:
k : str: The key for which the metadata type is being set.
data_type : Literal[“boolean”, “datetime”, “number”, “uuid”, “varchar”, “text”, “string”, “long_string”]
The type of metadata to be associated with the key. Must be a valid identifier.
“string” is an alias of “varchar”
“long_string” is an alias of “text”
Raises:
MetadataSchemaError - If the key k is already defined in the schema with a conflicting type.
ValueError - If data_type is not a valid type of metadata identifier.
set_scalar
def set_scalar(
k: str, *, data_type: Union[
Literal["boolean", "datetime", "number", "uuid", "varchar", "text",
"string", "long_string"],
MetadataSchemaScalarType,
]
) -> None
Sets a simple metadata type for a given key in the schema.
Alias of add_scalar
Arguments:
k : str: The key for which the metadata type is being set.
data_type : Literal[“boolean”, “datetime”, “number”, “uuid”, “varchar”, “text”, “string”, “long_string”]
The type of metadata to be associated with the key. Must be a valid identifier.
“string” is an alias of “varchar”
“long_string” is an alias of “text”
Raises:
MetadataSchemaError - If the key k is already defined in the schema with a conflicting type.
ValueError - If data_type is not a valid type of metadata identifier.
delete_key
def delete_key(k: str, *, hard: bool = False) -> None
Delete a metadata key from the schema.
Arguments:
k : str: The key for which the metadata type is being deleted.
hard - bool: If the deletion should prevent indexing of this key unconditionally.
Setting this to true prevents restoring the type definition in the future.
Raises:
MetadataSchemaError - If the key k is already deleted or not present in the schema
restore_key
def restore_key(k: str) -> None
Restore a deleted metadata key to its original value.
Arguments:
k : str: The key for which the metadata type is to be restored.
Raises:
MetadataSchemaError - If the key k is not already deleted or not present in the schema
keys
def keys() -> Sequence[str]
Returns a sequence of all keys defined in the metadata schema.
Returns:
Sequence[str] - A list of keys present in the metadata schema.
has_key
def has_key(k: str) -> bool
Check if any definition exists for a key.
Arguments:
k : str: The key for which the metadata type is to be retrieved.
is_key_deleted
def is_key_deleted(k: str) -> bool
Check if the key is defined as deleted. (Tombstone type)
Arguments:
k : str: The key for which the metadata type is to be retrieved.
get_key_type
def get_key_type(
k: str
) -> Union[Literal["boolean", "datetime", "uuid", "number", "varchar", "text",
"embedding", "enum", "geospatial"], None]
Retrieves the metadata type associated with a given key.
Arguments:
k : str: The key for which the metadata type is to be retrieved.
Returns:
Literal[“boolean”, “datetime”, “uuid”, “number”, “varchar”, “text”, “embedding”, “enum”, “geospatial”]: The metadata type associated with the key k.
Raises:
MetadataSchemaError - If the key k is not supported by the current SDK.
get_embedding_size
def get_embedding_size(k: str) -> int
Retrieves size associated with a given embedding.
Arguments:
k : str: The key for which the metadata type is to be retrieved.
Returns:
int - The size of the embedding
Raises:
MetadataSchemaError - If the key k is not defined in the schema or is not an embedding
get_enum_options
def get_enum_options(k: str) -> Sequence[str]
Retrieves all values associated with a given enum.
Arguments:
k : str: The key for which the metadata type is to be retrieved.
Returns:
Sequence[str] - The list of all values associated with an enum type.
Raises:
MetadataSchemaError - If the key k is not defined in the schema or is not an enum.