File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 77from labelbox .orm .db_object import DbObject , Updateable , BulkDeletable
88from labelbox .orm .model import Entity , Field , Relationship
99from labelbox .schema .data_row_metadata import DataRowMetadataField # type: ignore
10- from labelbox .schema .export_params import CatalogExportParams
10+ from labelbox .schema .export_params import CatalogExportParams , validate_catalog_export_params
1111from labelbox .schema .task import Task
1212from labelbox .schema .user import User # type: ignore
1313
@@ -177,7 +177,6 @@ def export_v2(client: 'Client',
177177 >>> task.wait_till_done()
178178 >>> task.result
179179 """
180- print ('export start' )
181180
182181 _params = params or CatalogExportParams ({
183182 "attachments" : False ,
@@ -191,6 +190,8 @@ def export_v2(client: 'Client',
191190 "project_ids" : None ,
192191 })
193192
193+ validate_catalog_export_params (_params )
194+
194195 mutation_name = "exportDataRowsInCatalog"
195196 create_task_query_str = """mutation exportDataRowsInCatalogPyApi($input: ExportDataRowsInCatalogInput!){
196197 %s(input: $input) {taskId} }
Original file line number Diff line number Diff line change 1919from labelbox .exceptions import MalformedQueryException
2020from labelbox .schema .data_row import DataRow
2121from labelbox .schema .export_filters import DatasetExportFilters , SharedExportFilters
22- from labelbox .schema .export_params import CatalogExportParams
22+ from labelbox .schema .export_params import CatalogExportParams , validate_catalog_export_params
2323from labelbox .schema .project import _validate_datetime
2424from labelbox .schema .task import Task
2525from labelbox .schema .user import User
@@ -570,6 +570,7 @@ def export_v2(self,
570570 "model_run_ids" : None ,
571571 "project_ids" : None ,
572572 })
573+ validate_catalog_export_params (_params )
573574
574575 _filters = filters or DatasetExportFilters ({
575576 "last_activity_at" : None ,
Original file line number Diff line number Diff line change 22
33from typing import Optional , List
44
5+ EXPORT_LIMIT = 30
6+
57from labelbox .schema .media_type import MediaType
68if sys .version_info >= (3 , 8 ):
79 from typing import TypedDict
@@ -32,4 +34,19 @@ class CatalogExportParams(DataRowParams):
3234
3335
3436class ModelRunExportParams (DataRowParams ):
35- predictions : Optional [bool ]
37+ predictions : Optional [bool ]
38+
39+
40+ def _validate_array_length (array , max_length , array_name ):
41+ if len (array ) > max_length :
42+ raise ValueError (f"{ array_name } cannot exceed { max_length } items" )
43+
44+
45+ def validate_catalog_export_params (params : CatalogExportParams ):
46+ if "model_run_ids" in params and params ["model_run_ids" ] is not None :
47+ _validate_array_length (params ["model_run_ids" ], EXPORT_LIMIT ,
48+ "model_run_ids" )
49+
50+ if "project_ids" in params and params ["project_ids" ] is not None :
51+ _validate_array_length (params ["project_ids" ], EXPORT_LIMIT ,
52+ "project_ids" )
Original file line number Diff line number Diff line change 33from labelbox .orm .db_object import DbObject
44from labelbox .orm .model import Entity , Field
55from labelbox .pagination import PaginatedCollection
6- from labelbox .schema .export_params import CatalogExportParams
6+ from labelbox .schema .export_params import CatalogExportParams , validate_catalog_export_params
77from labelbox .schema .task import Task
88from labelbox .schema .user import User
99
@@ -88,6 +88,7 @@ def export_v2(self,
8888 "model_run_ids" : None ,
8989 "project_ids" : None ,
9090 })
91+ validate_catalog_export_params (_params )
9192
9293 mutation_name = "exportDataRowsInSlice"
9394 create_task_query_str = """mutation exportDataRowsInSlicePyApi($input: ExportDataRowsInSliceInput!){
You can’t perform that action at this time.
0 commit comments