Skip to content

Commit 14d47c7

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
tod
1 parent 76d0276 commit 14d47c7

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3492,7 +3492,7 @@ def delete_annotations(
34923492
def attach_document_urls_to_project(
34933493
project: Union[NotEmptyStr, dict],
34943494
attachments: Union[Path, NotEmptyStr],
3495-
annotation_status: Optional[NotEmptyStr] = "NotStarted",
3495+
annotation_status: Optional[Status] = "NotStarted",
34963496
):
34973497
"""Link documents on external storage to SuperAnnotate.
34983498

src/superannotate/lib/core/usecases/images.py

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,18 +1317,17 @@ def validate_project_type(self):
13171317
constances.LIMITED_FUNCTIONS[self._project.project_type]
13181318
)
13191319

1320-
def validate_auth_data(self):
1321-
response = self._backend_client.get_s3_upload_auth_token(
1322-
team_id=self._project.team_id,
1323-
folder_id=self._folder.uuid,
1324-
project_id=self._project.uuid,
1325-
)
1326-
if "error" in response:
1327-
raise AppException(response.get("error"))
1328-
self._auth_data = response
1329-
13301320
@property
13311321
def auth_data(self):
1322+
if not self._auth_data:
1323+
response = self._backend_client.get_s3_upload_auth_token(
1324+
team_id=self._project.team_id,
1325+
folder_id=self._folder.uuid,
1326+
project_id=self._project.uuid,
1327+
)
1328+
if "error" in response:
1329+
raise AppException(response.get("error"))
1330+
self._auth_data = response
13321331
return self._auth_data
13331332

13341333
@property
@@ -3546,27 +3545,37 @@ def __init__(
35463545
self._annotation_status_code = annotation_status_code
35473546
self._image_quality_in_editor = image_quality_in_editor
35483547
self._limit = limit
3549-
self._auth_data = None
3550-
3551-
def validate_auth_data(self):
3552-
response = self._backend_service.get_s3_upload_auth_token(
3553-
team_id=self._project.team_id,
3554-
folder_id=self._folder.uuid,
3555-
project_id=self._project.uuid,
3556-
)
3557-
if "error" in response:
3558-
raise AppException(response.get("error"))
3559-
self._auth_data = response
3548+
self._limitation_response = None
35603549

35613550
@property
3562-
def upload_auth_data(self):
3563-
return self._auth_data
3551+
def limitation_response(self):
3552+
if not self._limitation_response:
3553+
self._limitation_response = self._backend_service.get_limitations(
3554+
team_id=self._project.team_id,
3555+
project_id=self._project.uuid,
3556+
folder_id=self._folder.uuid,
3557+
)
3558+
if not self._limitation_response.ok:
3559+
raise AppValidationException(self._limitation_response.error)
3560+
return self._limitation_response
3561+
3562+
def validate_limitations(self):
3563+
response = self.limitation_response
3564+
if not response.ok:
3565+
raise AppValidationException(response.error)
3566+
if not response.data.folder_limit.remaining_image_count:
3567+
raise AppValidationException(constances.UPLOAD_FOLDER_LIMIT_ERROR_MESSAGE)
3568+
elif not response.data.project_limit.remaining_image_count:
3569+
raise AppValidationException(constances.UPLOAD_PROJECT_LIMIT_ERROR_MESSAGE)
3570+
elif (
3571+
response.data.super_user_limit
3572+
and response.data.super_user_limit.remaining_image_count > 0
3573+
):
3574+
raise AppValidationException(constances.UPLOAD_USER_LIMIT_ERROR_MESSAGE)
35643575

35653576
@property
35663577
def limit(self):
3567-
if not self._limit:
3568-
return self.upload_auth_data.get("availableImageCount")
3569-
return self._limit
3578+
return self._limitation_response.data.folder_limit.remaining_image_count
35703579

35713580
def validate_project_type(self):
35723581
if self._project.project_type in constances.LIMITED_FUNCTIONS:

0 commit comments

Comments
 (0)