@@ -504,7 +504,7 @@ class UploadImageS3UseCase(BaseUseCase):
504504 def __init__ (
505505 self ,
506506 project : ProjectEntity ,
507- project_settings : BaseReadOnlyRepository ,
507+ project_settings : List [ ProjectSettingEntity ] ,
508508 image_path : str ,
509509 image : io .BytesIO ,
510510 s3_repo : BaseManageableRepository ,
@@ -535,7 +535,7 @@ def execute(self):
535535 huge_image , huge_width , huge_height = image_processor .generate_huge ()
536536 quality = 60
537537 if not self ._image_quality_in_editor :
538- for setting in self ._project_settings . get_all () :
538+ for setting in self ._project_settings :
539539 if setting .attribute == "ImageQuality" :
540540 quality = setting .value
541541 else :
@@ -679,7 +679,11 @@ def execute(self):
679679 folder_id = self ._folder .uuid ,
680680 images = [image .name for image in self ._attachments ],
681681 )
682- duplications = [image ["name" ] for image in duplications ]
682+ try :
683+ duplications = [image ["name" ] for image in duplications ]
684+ except Exception :
685+ print (duplications )
686+ raise
683687 meta = {}
684688 to_upload = []
685689 for image in self ._attachments :
@@ -1062,7 +1066,7 @@ def execute(self):
10621066 headers = annotations ["annotation_json_path" ]["headers" ],
10631067 )
10641068 if not response .ok :
1065- raise AppException (f "Couldn't load annotations." )
1069+ raise AppException ("Couldn't load annotations." )
10661070
10671071 image_annotations = response .json ()
10681072 from_project_annotation_classes = (
@@ -1153,7 +1157,7 @@ def execute(self):
11531157 headers = annotations ["annotation_bluemap_path" ]["headers" ],
11541158 )
11551159 if not response .ok :
1156- raise AppException (f "Couldn't load annotations." )
1160+ raise AppException ("Couldn't load annotations." )
11571161 self .to_project_s3_repo .insert (
11581162 S3FileEntity (
11591163 auth_data ["annotation_bluemap_path" ]["filePath" ], response .content
@@ -2082,7 +2086,7 @@ def execute(self):
20822086 headers = credentials ["annotation_json_path" ]["headers" ],
20832087 )
20842088 if not response .ok :
2085- logger .warning (f "Couldn't load annotations." )
2089+ logger .warning ("Couldn't load annotations." )
20862090 self ._response .data = data
20872091 return self ._response
20882092 data ["annotation_json" ] = response .json ()
@@ -2177,7 +2181,7 @@ def execute(self):
21772181 url = annotation_json_creds ["url" ], headers = annotation_json_creds ["headers" ],
21782182 )
21792183 if not response .ok :
2180- raise AppException (f "Couldn't load annotations." )
2184+ raise AppException ("Couldn't load annotations." )
21812185 data ["preannotation_json" ] = response .json ()
21822186 data ["preannotation_json_filename" ] = f"{ self ._image_name } { file_postfix } "
21832187 if self ._project .project_type == constances .ProjectType .PIXEL .value :
@@ -2254,7 +2258,7 @@ def execute(self):
22542258 headers = annotation_json_creds ["headers" ],
22552259 )
22562260 if not response .ok :
2257- logger .warning (f "Couldn't load annotations." )
2261+ logger .warning ("Couldn't load annotations." )
22582262 self ._response .data = (None , None )
22592263 return self ._response
22602264 data ["annotation_json" ] = response .json ()
@@ -2333,7 +2337,7 @@ def execute(self):
23332337 url = annotation_json_creds ["url" ], headers = annotation_json_creds ["headers" ],
23342338 )
23352339 if not response .ok :
2336- raise AppException (f "Couldn't load annotations." )
2340+ raise AppException ("Couldn't load annotations." )
23372341 data ["preannotation_json" ] = response .json ()
23382342 data ["preannotation_json_filename" ] = f"{ self ._image_name } { file_postfix } "
23392343 mask_path = None
@@ -3272,10 +3276,11 @@ def __init__(
32723276 self ,
32733277 project : ProjectEntity ,
32743278 folder : FolderEntity ,
3275- annotation_classes : BaseReadOnlyRepository ,
3279+ annotation_classes : List [ AnnotationClassEntity ] ,
32763280 folder_path : str ,
32773281 annotation_paths : List [str ],
32783282 backend_service_provider : SuerannotateServiceProvider ,
3283+ templates : List [dict ],
32793284 pre_annotation : bool = False ,
32803285 client_s3_bucket = None ,
32813286 ):
@@ -3288,6 +3293,7 @@ def __init__(
32883293 self ._annotation_paths = annotation_paths
32893294 self ._client_s3_bucket = client_s3_bucket
32903295 self ._pre_annotation = pre_annotation
3296+ self ._templates = templates
32913297
32923298 @property
32933299 def s3_client (self ):
@@ -3296,7 +3302,7 @@ def s3_client(self):
32963302 @property
32973303 def annotation_classes_name_map (self ) -> dict :
32983304 classes_data = defaultdict (dict )
3299- annotation_classes = self ._annotation_classes . get_all ()
3305+ annotation_classes = self ._annotation_classes
33003306 for annotation_class in annotation_classes :
33013307 class_info = {"id" : annotation_class .uuid }
33023308 if annotation_class .attribute_groups :
@@ -3322,11 +3328,8 @@ def annotation_postfix(self):
33223328 )
33233329
33243330 def get_templates_mapping (self ):
3325- templates = self ._backend_service .get_templates (
3326- team_id = self ._project .team_id
3327- ).get ("data" , [])
33283331 templates_map = {}
3329- for template in templates :
3332+ for template in self . _templates :
33303333 templates_map [template ["name" ]] = template ["id" ]
33313334 return templates_map
33323335
@@ -4271,7 +4274,7 @@ def __init__(
42714274 self ._project = project
42724275 self ._folder = folder
42734276 self ._folder_path = folder_path
4274- self ._settings = settings
4277+ self ._settings = settings . get_all ()
42754278 self ._s3_repo = s3_repo
42764279 self ._backend_client = backend_client
42774280 self ._image_quality_in_editor = image_quality_in_editor
0 commit comments