Skip to content

Commit 84a0ef8

Browse files
committed
update to include max datarow operations
1 parent aa644a1 commit 84a0ef8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

labelbox/schema/dataset.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
from labelbox.exceptions import InvalidQueryError, LabelboxError, ResourceNotFoundError, InvalidAttributeError
1616
from labelbox.orm.db_object import DbObject, Updateable, Deletable
1717
from labelbox.orm.model import Entity, Field, Relationship
18+
from labelbox.exceptions import MalformedQueryException
1819

1920
if TYPE_CHECKING:
2021
from labelbox import Task, User, DataRow
2122

2223
logger = logging.getLogger(__name__)
2324

25+
MAX_DATAROW_PER_API_OPERATION = 150000
26+
MAX_DATAROW_WITH_METADATA = 30000
27+
2428

2529
class Dataset(DbObject, Updateable, Deletable):
2630
""" A Dataset is a collection of DataRows.
@@ -393,14 +397,18 @@ def convert_item(item):
393397

394398
# TODO: If any datarows contain metadata, we're limiting max # of datarows
395399
# until we address performance issues with datarow create with metadata
396-
max_datarow_with_metadata = 30_000
397-
if (len(items) > max_datarow_with_metadata):
400+
if (len(items) > MAX_DATAROW_WITH_METADATA):
398401
for row in items:
399402
if 'metadata_fields' in row:
400-
raise ValueError(
401-
f"Cannot create more than {max_datarow_with_metadata} DataRows, if any DataRows contain metadata"
403+
raise MalformedQueryException(
404+
f"Cannot create more than {MAX_DATAROW_WITH_METADATA} DataRows, if any DataRows contain metadata"
402405
)
403406

407+
if len(items) > MAX_DATAROW_PER_API_OPERATION:
408+
raise MalformedQueryException(
409+
f"Cannot create more than {MAX_DATAROW_PER_API_OPERATION} DataRows per function call."
410+
)
411+
404412
with ThreadPoolExecutor(file_upload_thread_count) as executor:
405413
futures = [executor.submit(convert_item, item) for item in items]
406414
items = [future.result() for future in as_completed(futures)]

0 commit comments

Comments
 (0)