Skip to content

Commit

Permalink
better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiPetukhov committed Dec 30, 2024
1 parent 9caf028 commit 67c6ac2
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,23 @@ def images_bulk_add(
img_json[ApiField.HASH] = img_info.hash
img_data.append(img_json)

response = api.post(
"images.bulk.add",
{
ApiField.DATASET_ID: dataset_id,
ApiField.IMAGES: img_data,
ApiField.FORCE_METADATA_FOR_LINKS: False,
ApiField.SKIP_VALIDATION: True,
},
)
try:
response = api.post(
"images.bulk.add",
{
ApiField.DATASET_ID: dataset_id,
ApiField.IMAGES: img_data,
ApiField.FORCE_METADATA_FOR_LINKS: False,
ApiField.SKIP_VALIDATION: True,
},
)
except Exception as e:
if "Some users are not members of the destination group" in str(e):
raise ValueError(
"Unable to add images. Image creator is not a member of the destination team."
) from e
else:
raise e

results = []
for info_json in response.json():
Expand Down

0 comments on commit 67c6ac2

Please sign in to comment.