Skip to content

Commit 8adba16

Browse files
author
gdj0nes
committed
ADD: exception for exceeding max number of data rows
1 parent a5c8844 commit 8adba16

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

labelbox/schema/data_row_metadata.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from labelbox.schema.ontology import SchemaId
1111
from labelbox.utils import camel_case
1212

13+
_MAX_METADATA_FIELDS = 5
14+
1315

1416
class DataRowMetadataKind(Enum):
1517
number = "CustomMetadataNumber"
@@ -292,6 +294,8 @@ def _batch_upsert(
292294

293295
items = []
294296
for m in metadata:
297+
if len(m.fields) > _MAX_METADATA_FIELDS:
298+
raise ValueError(f"Cannot upload {len(m.fields)}, the max number is {_MAX_METADATA_FIELDS}")
295299
items.append(
296300
_UpsertBatchDataRowMetadata(
297301
data_row_id=m.data_row_id,
@@ -415,7 +419,7 @@ def _parse_upsert(
415419
elif schema.kind == DataRowMetadataKind.enum:
416420
parsed = _validate_enum_parse(schema, metadatum)
417421
elif schema.kind == DataRowMetadataKind.option:
418-
raise ValueError("An option id should not be as a schema id")
422+
raise ValueError("An Option id should not be set as the Schema id")
419423
else:
420424
raise ValueError(f"Unknown type: {schema}")
421425

0 commit comments

Comments
 (0)