DataRow

class labelbox.schema.data_row.DataRow(*args, **kwargs)[source]

Bases: DbObject, Updateable, BulkDeletable

Internal Labelbox representation of a single piece of data (e.g. image, video, text).

external_id

User-generated file name or identifier

Type:

str

global_key

User-generated globally unique identifier

Type:

str

row_data

Paths to local files are uploaded to Labelbox’s server. Otherwise, it’s treated as an external URL.

Type:

str

updated_at
Type:

datetime

created_at
Type:

datetime

media_attributes

generated media attributes for the data row

Type:

dict

metadata_fields

metadata associated with the data row

Type:

list

metadata

metadata associated with the data row as list of DataRowMetadataField. When importing Data Rows with metadata, use metadata_fields instead

Type:

list

dataset

ToOne relationship to Dataset

Type:

Relationship

created_by

ToOne relationship to User

Type:

Relationship

organization

ToOne relationship to Organization

Type:

Relationship

labels

ToMany relationship to Label

Type:

Relationship

attachments
Type:

Relationship

static bulk_delete(data_rows) None[source]

Deletes all the given DataRows.

Parameters:

data_rows (list of DataRow) – The DataRows to delete.

create_attachment(attachment_type, attachment_value, attachment_name=None) AssetAttachment[source]
Adds an AssetAttachment to a DataRow.

Labelers can view these attachments while labeling.

>>> datarow.create_attachment("TEXT", "This is a text message")
Parameters:
  • attachment_type (str) – Asset attachment type, must be one of: VIDEO, IMAGE, TEXT, IMAGE_OVERLAY (AttachmentType)

  • attachment_value (str) – Asset attachment value.

  • attachment_name (str) – (Optional) Asset attachment name.

Returns:

AssetAttachment DB object.

Raises:
  • ValueError – attachment_type must be one of the supported types.

  • ValueError – attachment_value must be a non-empty string.

static export(client: Client, data_rows: List[str | DataRow] | None = None, global_keys: List[str] | None = None, task_name: str | None = None, params: CatalogExportParams | None = None) ExportTask[source]

Creates a data rows export task with the given list, params and returns the task. :param client: client to use to make the export request :type client: Client :param data_rows: list of data row objects or data row ids to export :type data_rows: list of DataRow or str :param task_name: name of remote task :type task_name: str :param params: export params :type params: CatalogExportParams

>>>     dataset = client.get_dataset(DATASET_ID)
>>>     task = DataRow.export(
>>>         data_rows=[data_row.uid for data_row in dataset.data_rows.list()],
>>>             # or a list of DataRow objects: data_rows = data_set.data_rows.list()
>>>             # or a list of global_keys=["global_key_1", "global_key_2"],
>>>             # Note that exactly one of: data_rows or global_keys parameters can be passed in at a time
>>>             # and if data rows ids is present, global keys will be ignored
>>>         params={
>>>             "performance_details": False,
>>>             "label_details": True
>>>         })
>>>     task.wait_till_done()
>>>     task.result
static export_v2(client: Client, data_rows: List[str | DataRow] | None = None, global_keys: List[str] | None = None, task_name: str | None = None, params: CatalogExportParams | None = None) Task | ExportTask[source]

Creates a data rows export task with the given list, params and returns the task. :param client: client to use to make the export request :type client: Client :param data_rows: list of data row objects or data row ids to export :type data_rows: list of DataRow or str :param task_name: name of remote task :type task_name: str :param params: export params :type params: CatalogExportParams

>>>     dataset = client.get_dataset(DATASET_ID)
>>>     task = DataRow.export_v2(
>>>         data_rows=[data_row.uid for data_row in dataset.data_rows.list()],
>>>             # or a list of DataRow objects: data_rows = data_set.data_rows.list()
>>>             # or a list of global_keys=["global_key_1", "global_key_2"],
>>>             # Note that exactly one of: data_rows or global_keys parameters can be passed in at a time
>>>             # and if data rows ids is present, global keys will be ignored
>>>         params={
>>>             "performance_details": False,
>>>             "label_details": True
>>>         })
>>>     task.wait_till_done()
>>>     task.result
get_winning_label_id(project_id: str) str | None[source]
Retrieves the winning label ID, i.e. the one that was marked as the

best for a particular data row, in a project’s workflow.

Parameters:

project_id (str) – ID of the project containing the data row

update(**kwargs)[source]

Updates this DB object with new values. Values should be passed as key-value arguments with field names as keys: >>> db_object.update(name=”New name”, title=”A title”)

Kwargs:

Key-value arguments defining which fields should be updated for which values. Keys must be field names in this DB object’s type.

Raises:

InvalidAttributeError – if there exists a key in kwargs that’s not a field in this object type.

class labelbox.schema.data_row.KeyType(value)[source]

Bases: str, Enum

An enumeration.

AUTO = 'AUTO'

The key will be auto-generated. Only usable for creates

GKEY = 'GKEY'

A Global key, could be existing or non-existing

ID = 'ID'

An existing CUID