@@ -849,6 +849,7 @@ def execute(self) -> Response:
849849
850850class UploadImagesToProject (BaseInteractiveUseCase ):
851851 MAX_WORKERS = 10
852+ LIST_NAME_CHUNK_SIZE = 500
852853
853854 def __init__ (
854855 self ,
@@ -1023,24 +1024,30 @@ def filter_paths(self, paths: List[str]):
10231024 for path in paths :
10241025 name_path_map [Path (path ).name ].append (path )
10251026
1027+ CHUNK_SIZE = UploadImagesToProject .LIST_NAME_CHUNK_SIZE
10261028 filtered_paths = []
10271029 duplicated_paths = []
10281030 for file_name in name_path_map :
10291031 if len (name_path_map [file_name ]) > 1 :
10301032 duplicated_paths .append (name_path_map [file_name ][1 :])
10311033 filtered_paths .append (name_path_map [file_name ][0 ])
10321034
1033- response = self ._service_provider .items .list_by_names (
1034- project = self ._project ,
1035- folder = self ._folder ,
1036- names = [image .split ("/" )[- 1 ] for image in filtered_paths ],
1037- )
1038- if not response .ok :
1039- self ._response .errors = AppException (response .error )
1040- return self ._response
1035+ image_list = []
1036+ for i in range (0 , len (filtered_paths ), CHUNK_SIZE ):
1037+ response = self ._service_provider .items .list_by_names (
1038+ project = self ._project ,
1039+ folder = self ._folder ,
1040+ names = [
1041+ image .split ("/" )[- 1 ] for image in filtered_paths [i : i + CHUNK_SIZE ]
1042+ ],
1043+ )
10411044
1045+ if not response .ok :
1046+ raise AppException (response .error )
1047+ image_list .extend ([image .name for image in response .data ])
1048+
1049+ image_list = set (image_list )
10421050 images_to_upload = []
1043- image_list = [image .name for image in response .data ]
10441051
10451052 for path in filtered_paths :
10461053 if Path (path ).name not in image_list :
@@ -1593,15 +1600,14 @@ def fill_classes_data(self, annotations: dict):
15931600 attribute ["groupName" ] = annotation_class ["attribute_groups" ][
15941601 attribute ["groupId" ]
15951602 ]["name" ]
1596- if attribute [ "id" ] not in list (
1603+ if attribute . get ( "id" ) in list (
15971604 annotation_class ["attribute_groups" ][attribute ["groupId" ]][
15981605 "attributes"
15991606 ].keys ()
16001607 ):
1601- continue
1602- attribute ["name" ] = annotation_class ["attribute_groups" ][
1603- attribute ["groupId" ]
1604- ]["attributes" ][attribute ["id" ]]
1608+ attribute ["name" ] = annotation_class ["attribute_groups" ][
1609+ attribute ["groupId" ]
1610+ ]["attributes" ][attribute ["id" ]]
16051611
16061612 def execute (self ):
16071613 if self .is_valid ():
0 commit comments