File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change
1
+ import ast
1
2
import datetime
2
3
import json
3
4
import os
@@ -493,6 +494,8 @@ def single_upload(
493
494
)
494
495
image_id = uploaded_image ["id" ]
495
496
upload_retry_attempts = retry .retries
497
+ except rfapi .UploadError as e :
498
+ raise RuntimeError (f"Error uploading image: { self ._parse_upload_error (e )} " )
496
499
except BaseException as e :
497
500
uploaded_image = {"error" : e }
498
501
finally :
@@ -514,6 +517,8 @@ def single_upload(
514
517
annotation_labelmap = annotation_labelmap ,
515
518
overwrite = annotation_overwrite ,
516
519
)
520
+ except rfapi .UploadError as e :
521
+ raise RuntimeError (f"Error uploading annotation: { self ._parse_upload_error (e )} " )
517
522
except BaseException as e :
518
523
uploaded_annotation = {"error" : e }
519
524
finally :
@@ -546,6 +551,11 @@ def _annotation_params(self, annotation_path):
546
551
)
547
552
return annotation_name , annotation_string
548
553
554
+ def _parse_upload_error (self , error : rfapi .UploadError ) -> str :
555
+ dict_part = str (error ).split (": " , 2 )[2 ]
556
+ parsed_dict = ast .literal_eval (dict_part )
557
+ return parsed_dict .get ("message" )
558
+
549
559
def search (
550
560
self ,
551
561
like_image : str = None ,
You can’t perform that action at this time.
0 commit comments