@@ -137,6 +137,12 @@ def annotations_to_upload(self):
137137 self ._annotations_to_upload = annotations_to_upload
138138 return self ._annotations_to_upload
139139
140+ @property
141+ def missing_annotations (self ):
142+ if not self ._missing_annotations :
143+ self ._missing_annotations = []
144+ return self ._missing_annotations
145+
140146 def get_annotation_upload_data (
141147 self , image_ids : List [int ]
142148 ) -> UploadAnnotationAuthData :
@@ -162,6 +168,7 @@ def _upload_annotation(
162168 bucket ,
163169 ):
164170 try :
171+ self .reporter .disable_warnings ()
165172 response = UploadAnnotationUseCase (
166173 project = self ._project ,
167174 folder = self ._folder ,
@@ -190,6 +197,8 @@ def _upload_annotation(
190197 except Exception as e :
191198 logger .debug (str (e ), exc_info = True )
192199 return path , False
200+ finally :
201+ self .reporter .enable_warnings ()
193202
194203 def get_bucket_to_upload (self , ids : List [int ]):
195204 upload_data = self .get_annotation_upload_data (ids )
@@ -223,7 +232,9 @@ def _log_report(self):
223232 logger .warning (template .format ("', '" .join (values )))
224233 if self .reporter .custom_messages .get ("invalid_jsons" ):
225234 logger .warning (
226- f"Couldn't validate { len (self .reporter .custom_messages ['invalid_jsons' ])} /{ len (self ._annotations_to_upload + self ._missing_annotations )} annotations from { self ._folder_path } ."
235+ f"Couldn't validate { len (self .reporter .custom_messages ['invalid_jsons' ])} /"
236+ f"{ len (self .annotations_to_upload + self .missing_annotations )} annotations from { self ._folder_path } . "
237+ f"{ constances .USE_VALIDATE_MESSAGE } "
227238 )
228239
229240 def execute (self ):
@@ -281,7 +292,7 @@ def execute(self):
281292 self ._response .data = (
282293 uploaded_annotations ,
283294 failed_annotations ,
284- [annotation .path for annotation in self ._missing_annotations ],
295+ [annotation .path for annotation in self .missing_annotations ],
285296 )
286297 return self ._response
287298
@@ -477,12 +488,13 @@ def execute(self):
477488 )
478489 self ._images .update (self ._image )
479490 if self ._verbose :
480- logger .info (
481- "Uploading annotations for image %s in project %s." ,
482- str (self ._image .name ),
483- self ._project .name ,
491+ self .reporter .log_info (
492+ f"Uploading annotations for image { str (self ._image .name )} in project { self ._project .name } ."
484493 )
485494 else :
486- self ._response .errors = "Invalid json"
495+ self ._response .errors = constances . INVALID_JSON_MESSAGE
487496 self .reporter .store_message ("invalid_jsons" , self ._annotation_path )
497+ self .reporter .log_warning (
498+ f"Couldn't validate annotations. { constances .USE_VALIDATE_MESSAGE } "
499+ )
488500 return self ._response
0 commit comments