Skip to content

Commit 9e44993

Browse files
committed
Changed prepare_export
1 parent 77aa02c commit 9e44993

File tree

6 files changed

+29
-4
lines changed

6 files changed

+29
-4
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,6 @@ def set_image_annotation_status(
16301630
:rtype: dict
16311631
"""
16321632
project_name, folder_name = extract_project_folder(project)
1633-
project_entity = Controller.get_default()._get_project(project_name)
16341633
response = Controller.get_default().set_images_annotation_statuses(
16351634
project_name, folder_name, [image_name], annotation_status
16361635
)
@@ -1639,7 +1638,7 @@ def set_image_annotation_status(
16391638
image = (
16401639
Controller.get_default().get_item(project_name, folder_name, image_name).data
16411640
)
1642-
return ImageSerializer(image).serialize_by_project(project=project_entity)
1641+
return BaseSerializer(image).serialize()
16431642

16441643

16451644
@Trackable
@@ -2902,7 +2901,7 @@ def query(project: NotEmptyStr, query: Optional[NotEmptyStr]):
29022901
:param project: project name or folder path (e.g., “project1/folder1”)
29032902
:type project: str
29042903
2905-
:param query: SAQuL query string.
2904+
:param query: SAQuL(https://doc.superannotate.com/docs/query-search-1) query string.
29062905
:type query: str
29072906
29082907
:return: queried items’ metadata list

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(
3939
project: ProjectEntity,
4040
folder_names: List[str],
4141
backend_service_provider: SuperannotateServiceProvider,
42+
folders: BaseManageableRepository,
4243
include_fuse: bool,
4344
only_pinned: bool,
4445
annotation_statuses: List[str] = None,
@@ -50,6 +51,7 @@ def __init__(
5051
self._annotation_statuses = annotation_statuses
5152
self._include_fuse = include_fuse
5253
self._only_pinned = only_pinned
54+
self._folders = folders
5355

5456
def validate_only_pinned(self):
5557
if (
@@ -69,6 +71,19 @@ def validate_fuse(self):
6971
f"Include fuse functionality is not supported for projects containing {self._project.type} attached with URLs"
7072
)
7173

74+
def validate_folder_names(self):
75+
if self._folder_names:
76+
condition = (
77+
Condition("team_id", self._project.team_id, EQ) &
78+
Condition("project_id", self._project.id, EQ)
79+
)
80+
existing_folders = {folder.name for folder in self._folders.get_all(condition)}
81+
folder_names_set = set(self._folder_names)
82+
if not folder_names_set.issubset(existing_folders):
83+
raise AppException(
84+
f"Folder(s) {', '.join(folder_names_set - existing_folders)} does not exist"
85+
)
86+
7287
def execute(self):
7388
if self.is_valid():
7489
if self._project.upload_state == constances.UploadState.EXTERNAL.value:

src/superannotate/lib/infrastructure/controller.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ def prepare_export(
578578
use_case = usecases.PrepareExportUseCase(
579579
project=project,
580580
folder_names=folder_names,
581+
folders=self.folders,
581582
backend_service_provider=self._backend_client,
582583
include_fuse=include_fuse,
583584
only_pinned=only_pinned,

src/superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.3.3dev9"
1+
__version__ = "4.3.3dev10"

tests/integration/items/test_set_annotation_statuses.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,12 @@ def test_image_annotation_status_via_invalid_names(self):
7070
sa.set_annotation_statuses(
7171
self.PROJECT_NAME, "QualityCheck", ["self.EXAMPLE_IMAGE_1", "self.EXAMPLE_IMAGE_2"]
7272
)
73+
74+
def test_set_image_annotation_status(self):
75+
sa.attach_items(
76+
self.PROJECT_NAME, [self.ATTACHMENT_LIST[0]]
77+
)
78+
data = sa.set_image_annotation_status(
79+
self.PROJECT_NAME, self.ATTACHMENT_LIST[0]["name"], annotation_status="Completed"
80+
)
81+
assert data["annotation_status"] == "Completed"

tests/integration/test_get_exports.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from os.path import dirname
55

66
import src.superannotate as sa
7+
from src.superannotate import AppException
78
from tests.integration.base import BaseTestCase
89

910

0 commit comments

Comments
 (0)