Skip to content

Commit f7c413c

Browse files
authored
Merge pull request #200 from superannotateai/sdk_limitations
Added limitation validation
2 parents 7bcd4be + eba2e99 commit f7c413c

File tree

10 files changed

+631
-95
lines changed

10 files changed

+631
-95
lines changed

src/superannotate/lib/app/common.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,6 @@ def save_web_format(output_dir, classes, files_dict):
148148
json.dump(classes, fw)
149149

150150

151-
def dump_output(output_dir, platform, classes, files_dict):
152-
if platform == "Web":
153-
save_web_format(output_dir, classes, files_dict)
154-
else:
155-
save_desktop_format(output_dir, classes, files_dict)
156-
157-
158151
def write_to_json(output_path, json_data):
159152
with open(output_path, "w") as fw:
160153
json.dump(json_data, fw, indent=2)

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import tempfile
77
import time
88
import uuid
9-
from collections import Counter
10-
from collections import namedtuple
11-
from io import BytesIO
129
from pathlib import Path
1310
from typing import Iterable
1411
from typing import List

src/superannotate/lib/core/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@
6868
ProjectType.DOCUMENT.value: DEPRECATED_DOCUMENT_PROJECTS_MESSAGE,
6969
}
7070

71+
UPLOAD_FOLDER_LIMIT_ERROR_MESSAGE = "The number of items you want to upload exceeds the limit of 50 000 items per folder."
72+
UPLOAD_PROJECT_LIMIT_ERROR_MESSAGE = "The number of items you want to upload exceeds the limit of 500 000 items per project."
73+
UPLOAD_USER_LIMIT_ERROR_MESSAGE = "The number of items you want to upload exceeds the limit of your subscription plan."
74+
75+
ATTACH_FOLDER_LIMIT_ERROR_MESSAGE = "The number of items you want to attach exceeds the limit of 50 000 items per folder."
76+
ATTACH_PROJECT_LIMIT_ERROR_MESSAGE = "The number of items you want to attach exceeds the limit of 500 000 items per project."
77+
ATTACH_USER_LIMIT_ERROR_MESSAGE = "The number of items you want to attach exceeds the limit of your subscription plan."
78+
79+
COPY_FOLDER_LIMIT_ERROR_MESSAGE = (
80+
"The number of items you want to copy exceeds the limit of 50 000 items per folder."
81+
)
82+
7183
__version__ = "?"
7284

7385
__alL__ = (

src/superannotate/lib/core/service_types.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
from typing import Any
22
from typing import Dict
3-
from typing import List
3+
from typing import Optional
44
from typing import Union
5+
from typing import List
56

6-
from lib.core.exceptions import AppException
77
from pydantic import BaseModel
88
from pydantic import Extra
99

1010

11+
class ErrorMessage(BaseModel):
12+
error: str
13+
14+
15+
class Limit(BaseModel):
16+
max_image_count: int
17+
remaining_image_count: int
18+
19+
1120
class UserLimits(BaseModel):
12-
super_user_limit: int
13-
project_limit: int
14-
folder_limit: int
15-
16-
def has_enough_slots(self, count: int):
17-
if count > self.super_user_limit:
18-
raise AppException(
19-
"The number of items you want to upload exceeds the limit of your subscription plan."
20-
)
21-
if count > self.project_limit:
22-
raise AppException(
23-
"You have exceeded the limit of 500 000 items per project."
24-
)
25-
if count > self.folder_limit:
26-
raise AppException(
27-
"“You have exceeded the limit of 50 000 items per folder."
28-
)
29-
return True
21+
super_user_limit: Optional[Limit]
22+
project_limit: Limit
23+
folder_limit: Limit
3024

3125

3226
class UploadAnnotationAuthData(BaseModel):

src/superannotate/lib/core/serviceproviders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def get_annotations_delete_progress(
315315
):
316316
raise NotImplementedError
317317

318-
def get_limits(
318+
def get_limitations(
319319
self, team_id: int, project_id: int, folder_id: int = None
320320
) -> ServiceResponse:
321321
raise NotImplementedError

0 commit comments

Comments
 (0)