@@ -343,30 +343,27 @@ async def run_workers(self, items_to_upload: List[ItemToUpload]):
343343 def execute (self ):
344344 if self .is_valid ():
345345 failed , skipped = [], []
346- unique_annotations = []
347- annotation_names_set = set ()
346+ name_annotation_map = {}
348347 for annotation in self ._annotations :
349348 try :
350349 name = annotation ["metadata" ]["name" ]
351- if name not in annotation_names_set :
352- annotation_names_set .add (name )
353- unique_annotations .append (annotation )
350+ name_annotation_map [name ] = annotation
354351 except KeyError :
355352 failed .append (annotation )
356353 logger .info (
357- f"Uploading { len (unique_annotations )} /{ len (self ._annotations )} "
354+ f"Uploading { len (name_annotation_map )} /{ len (self ._annotations )} "
358355 f"annotations to the project { self ._project .name } ."
359356 )
360- existing_items = self .list_existing_items (list (annotation_names_set ))
357+ existing_items = self .list_existing_items (list (name_annotation_map . keys () ))
361358 name_item_map = {i .name : i for i in existing_items }
362- len_existing , len_provided = len (existing_items ), len (annotation_names_set )
359+ len_existing , len_provided = len (existing_items ), len (name_annotation_map )
363360 if len_existing < len_provided :
364361 logger .warning (
365362 f"Couldn't find { len_provided - len_existing } /{ len_provided } "
366363 "items in the given directory that match the annotations."
367364 )
368365 items_to_upload : List [ItemToUpload ] = []
369- for annotation in unique_annotations :
366+ for annotation in name_annotation_map . values () :
370367 annotation_name = annotation ["metadata" ]["name" ]
371368 item = name_item_map .get (annotation_name )
372369 if item :
0 commit comments