Skip to content

Commit 865a020

Browse files
committed
Merge branch 're-design-sdk' of https://github.com/superannotateai/superannotate-python-sdk into re-design-sdk
2 parents 3f89ae0 + 73f62f3 commit 865a020

File tree

8 files changed

+40
-18
lines changed

8 files changed

+40
-18
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
minversion = 3.0
33
log_cli=true
44
python_files = test_*.py
5-
;addopts = -n32 --dist=loadscope
5+
addopts = -n32 --dist=loadscope

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pydicom>=2.0.0
22
boto3>=1.14.53
33
requests==2.26.0
44
requests-toolbelt>=0.9.1
5-
tqdm>=4.48.2
5+
tqdm=4.48.2
66
pillow>=7.2.0
77
numpy>=1.19.0
88
matplotlib>=3.3.1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3679,7 +3679,7 @@ def delete_annotations(project: str, image_names: List[str] = None):
36793679
project_name, folder_name = extract_project_folder(project)
36803680

36813681
response = controller.delete_annotations(
3682-
project_name=project, folder_name=folder_name, image_names=image_names
3682+
project_name=project_name, folder_name=folder_name, image_names=image_names
36833683
)
36843684
if response.errors:
36853685
raise AppException(response.errors)

src/superannotate/lib/core/enums.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def get_value(cls, name):
2323
if enum.name.lower() == name.lower():
2424
return enum.value
2525

26+
@classmethod
27+
def values(cls):
28+
return [enum.name.lower() for enum in list(cls)]
29+
2630

2731
class ProjectType(BaseTitledEnum):
2832
VECTOR = "Vector", 1

src/superannotate/lib/core/usecases.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,8 @@ def execute(self):
682682
folder_id=self._folder.uuid,
683683
images=[image.name for image in self._attachments],
684684
)
685+
if isinstance(response, dict) and "error" in response:
686+
raise AppException(response["error"])
685687
duplications = [image["name"] for image in response]
686688
meta = {}
687689
to_upload = []
@@ -4303,6 +4305,16 @@ def exclude_file_patterns(self):
43034305
return constances.DEFAULT_FILE_EXCLUDE_PATTERNS
43044306
return self._exclude_file_patterns
43054307

4308+
def validate_annotation_status(self):
4309+
if self._annotation_status and self._annotation_status.lower() not in constances.AnnotationStatus.values():
4310+
raise AppValidationException("Invalid annotations status")
4311+
4312+
def validate_extensions(self):
4313+
if self._extensions and not all(
4314+
[extension in constances.DEFAULT_IMAGE_EXTENSIONS for extension in self._extensions]
4315+
):
4316+
raise AppValidationException("")
4317+
43064318
def validate_project_type(self):
43074319
if self._project.project_type == constances.ProjectType.VIDEO.value:
43084320
raise AppValidationException(
@@ -4511,7 +4523,7 @@ def execute(self) -> Response:
45114523

45124524
if self._folder.name == "root" and not self._image_names:
45134525
response = self._backend_service.delete_image_annotations(
4514-
project_id=self._project.uuid, team_id=self._project.team_id,
4526+
project_id=self._project.uuid, team_id=self._project.team_id, image_names=self._image_names
45154527
)
45164528
else:
45174529
response = self._backend_service.delete_image_annotations(
@@ -4540,7 +4552,7 @@ def execute(self) -> Response:
45404552
logger.info("Annotations deleted")
45414553
break
45424554
else:
4543-
self._response.errors = AppException("Invalid image names.")
4555+
self._response.errors = AppException("Invalid image names or empty folder.")
45444556
return self._response
45454557

45464558

src/superannotate/lib/infrastructure/controller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,12 @@ def get_project_workflow(self, project_name: str):
708708

709709
def search_annotation_classes(self, project_name: str, name_prefix: str = None):
710710
project_entity = self._get_project(project_name)
711+
condition = Condition("name", name_prefix, EQ) if name_prefix else None
711712
use_case = usecases.GetAnnotationClassesUseCase(
712713
classes=AnnotationClassRepository(
713714
service=self._backend_client, project=project_entity
714715
),
715-
condition=Condition("name", name_prefix, EQ),
716+
condition=condition
716717
)
717718
return use_case.execute()
718719

tests/integration/test_annotation_delete.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class TestAnnotationDelete(BaseTestCase):
1010
PROJECT_NAME = "TestAnnotationDelete"
1111
PROJECT_DESCRIPTION = "desc"
1212
PROJECT_TYPE = "Vector"
13+
TEST_FOLDER_NAME = "folder"
1314
TEST_FOLDER_PATH = "data_set/sample_project_vector_single_image"
1415
EXAMPLE_IMAGE_1 = "example_image_1.jpg"
1516
EXAMPLE_IMAGE_2 = "example_image_2.jpg"
@@ -48,7 +49,7 @@ def test_delete_annotations(self):
4849
@pytest.mark.skip(
4950
"waiting for deployment to dev",
5051
)
51-
def test_delete_annotations_by_not_exsisting_name(self):
52+
def test_delete_annotations_by_not_existing_name(self):
5253
sa.upload_images_from_folder_to_project(
5354
self.PROJECT_NAME, self.folder_path, annotation_status="InProgress"
5455
)
@@ -59,3 +60,4 @@ def test_delete_annotations_by_not_exsisting_name(self):
5960
self.PROJECT_NAME, f"{self.folder_path}"
6061
)
6162
self.assertRaises(Exception, sa.delete_annotations, self.PROJECT_NAME, [self.EXAMPLE_IMAGE_2])
63+

tests/profiling/profiling.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@
3232
# print(results)
3333
# print(sum(results)/10)
3434

35-
import time
36-
results = []
37-
projects = "11", "22", "33", "44", "55", "66", "77", "88", "99"
38-
39-
for project in projects:
40-
start = time.time()
41-
sa.search_annotation_classes(project)
42-
end = time.time()
43-
results.append(end-start)
35+
# import time
36+
# results = []
37+
# projects = "11", "22", "33", "44", "55", "66", "77", "88", "99"
38+
#
39+
# for project in projects:
40+
# start = time.time()
41+
# sa.search_annotation_classes(project)
42+
# end = time.time()
43+
# results.append(end-start)
44+
#
45+
# print(results)
46+
# print(sum(results)/9)
4447

45-
print(results)
46-
print(sum(results)/9)
48+
from src.superannotate.lib.core.enums import AnnotationStatus
4749

50+
pass

0 commit comments

Comments
 (0)