@@ -129,7 +129,10 @@ def execute(self):
129129 if not projects :
130130 self ._response .errors = AppException ("Project not found." )
131131 else :
132- project = next ((project for project in projects if project .name == self ._name ), None )
132+ project = next (
133+ (project for project in projects if project .name == self ._name ),
134+ None ,
135+ )
133136 if not project :
134137 self ._response .errors = AppException ("Project not found" )
135138 self ._response .data = project
@@ -3156,6 +3159,7 @@ def execute(self):
31563159
31573160class UploadAnnotationsUseCase (BaseUseCase ):
31583161 MAX_WORKERS = 10
3162+
31593163 def __init__ (
31603164 self ,
31613165 project : ProjectEntity ,
@@ -3335,9 +3339,18 @@ def execute(self):
33353339 else :
33363340 from_s3 = None
33373341
3338- with concurrent .futures .ThreadPoolExecutor (max_workers = self .MAX_WORKERS ) as executor :
3342+ with concurrent .futures .ThreadPoolExecutor (
3343+ max_workers = self .MAX_WORKERS
3344+ ) as executor :
33393345 for image_id , image_info in auth_data ["images" ].items ():
3340- executor .submit (self .upload_to_s3 , image_id , image_info , bucket , from_s3 , image_id_name_map )
3346+ executor .submit (
3347+ self .upload_to_s3 ,
3348+ image_id ,
3349+ image_info ,
3350+ bucket ,
3351+ from_s3 ,
3352+ image_id_name_map ,
3353+ )
33413354
33423355 uploaded_annotations = [annotation .path for annotation in annotations_to_upload ]
33433356 missing_annotations = [annotation .path for annotation in missing_annotations ]
@@ -3353,7 +3366,9 @@ def execute(self):
33533366 )
33543367 return self ._response
33553368
3356- def upload_to_s3 (self , image_id : int , image_info , bucket , from_s3 , image_id_name_map ):
3369+ def upload_to_s3 (
3370+ self , image_id : int , image_info , bucket , from_s3 , image_id_name_map
3371+ ):
33573372 if from_s3 :
33583373 file = io .BytesIO ()
33593374 s3_object = from_s3 .Object (
@@ -3367,13 +3382,11 @@ def upload_to_s3(self, image_id: int, image_info, bucket, from_s3, image_id_name
33673382
33683383 self .fill_classes_data (annotation_json )
33693384 bucket .put_object (
3370- Key = image_info ["annotation_json_path" ],
3371- Body = json .dumps (annotation_json ),
3385+ Key = image_info ["annotation_json_path" ], Body = json .dumps (annotation_json ),
33723386 )
33733387 if self ._project .project_type == constances .ProjectType .PIXEL .value :
33743388 mask_filename = (
3375- image_id_name_map [image_id ].name
3376- + constances .ANNOTATION_MASK_POSTFIX
3389+ image_id_name_map [image_id ].name + constances .ANNOTATION_MASK_POSTFIX
33773390 )
33783391 if from_s3 :
33793392 file = io .BytesIO ()
@@ -3383,9 +3396,7 @@ def upload_to_s3(self, image_id: int, image_info, bucket, from_s3, image_id_name
33833396 s3_object .download_file (file )
33843397 file .seek (0 )
33853398 else :
3386- with open (
3387- f"{ self ._folder_path } /{ mask_filename } " , "rb"
3388- ) as mask_file :
3399+ with open (f"{ self ._folder_path } /{ mask_filename } " , "rb" ) as mask_file :
33893400 file = io .BytesIO (mask_file .read ())
33903401
33913402 bucket .put_object (Key = image_info ["annotation_bluemap_path" ], Body = file )
@@ -4347,7 +4358,9 @@ def execute(self):
43474358 folder = self ._folder ,
43484359 limit = self .auth_data ["availableImageCount" ],
43494360 backend_service_provider = self ._backend_client ,
4350- attachments = [image .entity for image in uploaded_images [i : i + 100 ]],
4361+ attachments = [
4362+ image .entity for image in uploaded_images [i : i + 100 ]
4363+ ],
43514364 annotation_status = self ._annotation_status ,
43524365 ).execute ()
43534366
0 commit comments