|
15 | 15 | from labelbox.exceptions import InvalidQueryError, LabelboxError, ResourceNotFoundError, InvalidAttributeError |
16 | 16 | from labelbox.orm.db_object import DbObject, Updateable, Deletable |
17 | 17 | from labelbox.orm.model import Entity, Field, Relationship |
| 18 | +from labelbox.exceptions import MalformedQueryException |
18 | 19 |
|
19 | 20 | if TYPE_CHECKING: |
20 | 21 | from labelbox import Task, User, DataRow |
21 | 22 |
|
22 | 23 | logger = logging.getLogger(__name__) |
23 | 24 |
|
| 25 | +MAX_DATAROW_PER_API_OPERATION = 150000 |
| 26 | +MAX_DATAROW_WITH_METADATA = 30000 |
| 27 | + |
24 | 28 |
|
25 | 29 | class Dataset(DbObject, Updateable, Deletable): |
26 | 30 | """ A Dataset is a collection of DataRows. |
@@ -393,14 +397,18 @@ def convert_item(item): |
393 | 397 |
|
394 | 398 | # TODO: If any datarows contain metadata, we're limiting max # of datarows |
395 | 399 | # 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): |
398 | 401 | for row in items: |
399 | 402 | 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" |
402 | 405 | ) |
403 | 406 |
|
| 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 | + |
404 | 412 | with ThreadPoolExecutor(file_upload_thread_count) as executor: |
405 | 413 | futures = [executor.submit(convert_item, item) for item in items] |
406 | 414 | items = [future.result() for future in as_completed(futures)] |
|
0 commit comments