DataRow Metadata

class labelbox.schema.data_row_metadata.DataRowMetadata(*, globalKey: str | None = None, dataRowId: str | None = None, fields: List[DataRowMetadataField])[source]

Bases: _CamelCaseMixin

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'populate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'data_row_id': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='dataRowId', alias_priority=1), 'fields': FieldInfo(annotation=List[labelbox.schema.data_row_metadata.DataRowMetadataField], required=True, alias='fields', alias_priority=1), 'global_key': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='globalKey', alias_priority=1)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class labelbox.schema.data_row_metadata.DataRowMetadataBatchResponse(*, globalKey: str | None = None, dataRowId: str | None = None, error: str | None = None, fields: List[DataRowMetadataField | str])[source]

Bases: _CamelCaseMixin

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'populate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'data_row_id': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='dataRowId', alias_priority=1), 'error': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='error', alias_priority=1), 'fields': FieldInfo(annotation=List[Union[labelbox.schema.data_row_metadata.DataRowMetadataField, Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=25), MaxLen(max_length=25)])]]], required=True, alias='fields', alias_priority=1), 'global_key': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='globalKey', alias_priority=1)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class labelbox.schema.data_row_metadata.DataRowMetadataField(*, schemaId: str | None = None, name: str | None = None, value: Any)[source]

Bases: _CamelCaseMixin

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'populate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'name': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='name', alias_priority=1), 'schema_id': FieldInfo(annotation=Union[Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=25), MaxLen(max_length=25)])], NoneType], required=False, default=None, alias='schemaId', alias_priority=1), 'value': FieldInfo(annotation=Any, required=True, alias='value', alias_priority=1)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class labelbox.schema.data_row_metadata.DataRowMetadataKind(value)[source]

Bases: Enum

An enumeration.

class labelbox.schema.data_row_metadata.DataRowMetadataOntology(client)[source]

Bases: object

Ontology for data row metadata

Metadata provides additional context for a data rows. Metadata is broken into two classes reserved and custom. Reserved fields are defined by Labelbox and used for creating specific experiences in the platform.

>>> mdo = client.get_data_row_metadata_ontology()
bulk_delete(deletes: List[DeleteDataRowMetadata]) List[DataRowMetadataBatchResponse][source]

Delete metadata from a datarow by specifiying the fields you want to remove

>>> delete = DeleteDataRowMetadata(
>>>                 data_row_id=UniqueId("datarow-id"),
>>>                 fields=[
>>>                        "schema-id-1",
>>>                        "schema-id-2"
>>>                        ...
>>>                    ]
>>>    )
>>> mdo.batch_delete([metadata])
>>> delete = DeleteDataRowMetadata(
>>>                 data_row_id=GlobalKey("global-key"),
>>>                 fields=[
>>>                        "schema-id-1",
>>>                        "schema-id-2"
>>>                        ...
>>>                    ]
>>>    )
>>> mdo.batch_delete([metadata])
>>> delete = DeleteDataRowMetadata(
>>>                 data_row_id="global-key",
>>>                 fields=[
>>>                        "schema-id-1",
>>>                        "schema-id-2"
>>>                        ...
>>>                    ]
>>>    )
>>> mdo.batch_delete([metadata])
Parameters:

deletes – Data row and schema ids to delete For data row, we support UniqueId, str, and GlobalKey. If you pass a str, we will assume it is a UniqueId Do not pass a mix of data row ids and global keys in the same list

Returns:

list of unsuccessful deletions. An empty list means all data rows were successfully deleted.

bulk_export(data_row_ids: List[str]) List[DataRowMetadata][source]
bulk_export(data_row_ids: UniqueIds | GlobalKeys) List[DataRowMetadata]

Exports metadata for a list of data rows

>>> mdo.bulk_export([data_row.uid for data_row in data_rows])
Parameters:
  • data_row_ids – List of data data rows to fetch metadata for. This can be a list of strings or a DataRowIdentifiers object

  • class. (DataRowIdentifier objects are lists of ids or global keys. A DataIdentifier object can be a UniqueIds or GlobalKeys) –

Returns:

A list of DataRowMetadata. There will be one DataRowMetadata for each data_row_id passed in. This is true even if the data row does not have any meta data. Data rows without metadata will have empty fields.

bulk_upsert(metadata: List[DataRowMetadata]) List[DataRowMetadataBatchResponse][source]

Upsert metadata to a list of data rows

You may specify data row by either data_row_id or global_key

>>> metadata = DataRowMetadata(
>>>                 data_row_id="datarow-id", # Alternatively, set global_key="global-key"
>>>                 fields=[
>>>                        DataRowMetadataField(schema_id="schema-id", value="my-message"),
>>>                        ...
>>>                    ]
>>>    )
>>> mdo.batch_upsert([metadata])
Parameters:

metadata – List of DataRow Metadata to upsert

Returns:

list of unsuccessful upserts. An empty list means the upload was successful.

create_schema(name: str, kind: DataRowMetadataKind, options: List[str] | None = None) DataRowMetadataSchema[source]

Create metadata schema

>>> mdo.create_schema(name, kind, options)
Parameters:
  • name (str) – Name of metadata schema

  • kind (DataRowMetadataKind) – Kind of metadata schema as DataRowMetadataKind

  • options (List[str]) – List of Enum options

Returns:

Created metadata schema as DataRowMetadataSchema

Raises:

KeyError – When provided name is not a valid custom metadata

delete_schema(name: str) bool[source]

Delete metadata schema

>>> mdo.delete_schema(name)
Parameters:

name – Name of metadata schema to delete

Returns:

True if deletion is successful, False if unsuccessful

Raises:

KeyError – When provided name is not a valid custom metadata

get_by_name(name: str) DataRowMetadataSchema | Dict[str, DataRowMetadataSchema][source]

Get metadata by name

>>> mdo.get_by_name(name)
Parameters:

name (str) – Name of metadata schema

Returns:

Metadata schema as DataRowMetadataSchema or dict, in case of Enum metadata

Raises:

KeyError – When provided name is not presented in neither reserved nor custom metadata list

parse_metadata(unparsed: List[Dict[str, List[str | Dict]]]) List[DataRowMetadata][source]

Parse metadata responses

>>> mdo.parse_metadata([metadata])
Parameters:

unparsed – An unparsed metadata export

Returns:

List of DataRowMetadata

Return type:

metadata

parse_metadata_fields(unparsed: List[Dict[str, Dict]]) List[DataRowMetadataField][source]

Parse metadata fields as list of DataRowMetadataField

>>> mdo.parse_metadata_fields([metadata_fields])
Parameters:

unparsed – An unparsed list of metadata represented as a dict containing ‘schemaId’ and ‘value’

Returns:

List of DataRowMetadataField

Return type:

metadata

parse_upsert_metadata(metadata_fields) List[Dict[str, Any]][source]
Converts either DataRowMetadataField or a dictionary representation

of DataRowMetadataField into a validated, flattened dictionary of metadata fields that are used to create data row metadata. Used internally in Dataset.create_data_rows()

Parameters:

metadata_fields – List of DataRowMetadataField or a dictionary representation of DataRowMetadataField

Returns:

List of dictionaries representing a flattened view of metadata fields

refresh_ontology()[source]

Update the DataRowMetadataOntology instance with the latest metadata ontology schemas

update_enum_option(name: str, option: str, new_option: str) DataRowMetadataSchema[source]

Update Enum metadata schema option

>>> mdo.update_enum_option(name, option, new_option)
Parameters:
  • name (str) – Name of metadata schema to update

  • option (str) – Name of Enum option to update

  • new_option (str) – New name of Enum option

Returns:

Updated metadata schema as DataRowMetadataSchema

Raises:

KeyError – When provided name is not a valid custom metadata

update_schema(name: str, new_name: str) DataRowMetadataSchema[source]

Update metadata schema

>>> mdo.update_schema(name, new_name)
Parameters:
  • name (str) – Current name of metadata schema

  • new_name (str) – New name of metadata schema

Returns:

Updated metadata schema as DataRowMetadataSchema

Raises:

KeyError – When provided name is not a valid custom metadata

class labelbox.schema.data_row_metadata.DataRowMetadataSchema(*, uid: str, name: str, reserved: bool, kind: DataRowMetadataKind, options: List[DataRowMetadataSchema] | None = None, parent: str | None = None)[source]

Bases: BaseModel

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'kind': FieldInfo(annotation=DataRowMetadataKind, required=True), 'name': FieldInfo(annotation=str, required=True, metadata=[BeforeValidator(func=<function <lambda>>), MinLen(min_length=1), MaxLen(max_length=100)]), 'options': FieldInfo(annotation=Union[List[labelbox.schema.data_row_metadata.DataRowMetadataSchema], NoneType], required=False, default=None), 'parent': FieldInfo(annotation=Union[Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=25), MaxLen(max_length=25)])], NoneType], required=False, default=None), 'reserved': FieldInfo(annotation=bool, required=True), 'uid': FieldInfo(annotation=str, required=True, metadata=[MinLen(min_length=25), MaxLen(max_length=25)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class labelbox.schema.data_row_metadata.DeleteDataRowMetadata(*, dataRowId: str | UniqueId | GlobalKey = None, fields: List[str])[source]

Bases: _CamelCaseMixin

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'populate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'data_row_id': FieldInfo(annotation=Union[str, UniqueId, GlobalKey], required=False, default=None, alias='dataRowId', alias_priority=1), 'fields': FieldInfo(annotation=List[Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=25), MaxLen(max_length=25)])]], required=True, alias='fields', alias_priority=1)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.