@@ -2082,6 +2082,9 @@ def execute(self):
20822082 file_postfix = "___objects.json"
20832083 else :
20842084 file_postfix = "___pixel.json"
2085+ data ["annotation_mask_filename" ] = f"{ self ._image_name } ___save.png"
2086+ data ["annotation_json_filename" ] = f"{ self ._image_name } { file_postfix } "
2087+
20852088 response = requests .get (
20862089 url = credentials ["annotation_json_path" ]["url" ],
20872090 headers = credentials ["annotation_json_path" ]["headers" ],
@@ -2099,7 +2102,6 @@ def execute(self):
20992102 headers = annotation_blue_map_creds ["headers" ],
21002103 )
21012104 data ["annotation_mask" ] = io .BytesIO (response .content )
2102- data ["annotation_mask_filename" ] = f"{ self ._image_name } ___save.png"
21032105
21042106 self ._response .data = data
21052107
@@ -4487,12 +4489,13 @@ def execute(self):
44874489
44884490class DeleteAnnotations (BaseUseCase ):
44894491 POLL_AWAIT_TIME = 2
4492+
44904493 def __init__ (
4491- self ,
4492- project : ProjectEntity ,
4493- folder : FolderEntity ,
4494- backend_service : SuerannotateServiceProvider ,
4495- image_names : Optional [List [str ]] = None ,
4494+ self ,
4495+ project : ProjectEntity ,
4496+ folder : FolderEntity ,
4497+ backend_service : SuerannotateServiceProvider ,
4498+ image_names : Optional [List [str ]] = None ,
44964499 ):
44974500 super ().__init__ ()
44984501 self ._project = project
@@ -4504,20 +4507,34 @@ def execute(self) -> Response:
45044507
45054508 if self ._folder .name == "root" and not self ._image_names :
45064509 poll_id = self ._backend_service .delete_image_annotations (
4507- project_id = self ._project .uuid ,
4508- team_id = self ._project .team_id ,
4510+ project_id = self ._project .uuid , team_id = self ._project .team_id ,
45094511 )
45104512 else :
45114513 poll_id = self ._backend_service .delete_image_annotations (
45124514 project_id = self ._project .uuid ,
45134515 team_id = self ._project .team_id ,
45144516 folder_id = self ._folder .uuid ,
45154517 image_names = self ._image_names ,
4516- )
4518+ )
45174519
45184520 if poll_id :
45194521 timeout_start = time .time ()
45204522 while time .time () < timeout_start + self .POLL_AWAIT_TIME :
4521- var = self ._backend_service .get_annotations_delete_progress (
4522- self ._project .uuid , self ._project .team_id , poll_id )
4523-
4523+ progress = int (
4524+ self ._backend_service .get_annotations_delete_progress (
4525+ project_id = self ._project .uuid ,
4526+ team_id = self ._project .team_id ,
4527+ poll_id = poll_id ,
4528+ ).get ("process" , - 1 )
4529+ )
4530+ if 0 < progress < 100 :
4531+ logger .info (f"Delete annotations in progress { progress } /100" )
4532+ elif 0 > progress :
4533+ self ._response .errors = "Annotations delete fails."
4534+ break
4535+ else :
4536+ logger .info (f"Annotations deleted" )
4537+ break
4538+ else :
4539+ self ._response .errors = AppException ("Invalid image names." )
4540+ return self ._response
0 commit comments