Skip to content

Commit 678912a

Browse files
committed
fix: raise UploadErrors for images and annotations
1 parent e27fcde commit 678912a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

roboflow/core/project.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ast
12
import datetime
23
import json
34
import os
@@ -493,6 +494,8 @@ def single_upload(
493494
)
494495
image_id = uploaded_image["id"]
495496
upload_retry_attempts = retry.retries
497+
except rfapi.UploadError as e:
498+
raise RuntimeError(f"Error uploading image: {self._parse_upload_error(e)}")
496499
except BaseException as e:
497500
uploaded_image = {"error": e}
498501
finally:
@@ -514,6 +517,8 @@ def single_upload(
514517
annotation_labelmap=annotation_labelmap,
515518
overwrite=annotation_overwrite,
516519
)
520+
except rfapi.UploadError as e:
521+
raise RuntimeError(f"Error uploading annotation: {self._parse_upload_error(e)}")
517522
except BaseException as e:
518523
uploaded_annotation = {"error": e}
519524
finally:
@@ -546,6 +551,11 @@ def _annotation_params(self, annotation_path):
546551
)
547552
return annotation_name, annotation_string
548553

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+
549559
def search(
550560
self,
551561
like_image: str = None,

0 commit comments

Comments
 (0)