Skip to content

Commit 42075d1

Browse files
authored
Merge pull request #699 from superannotateai/FRIDAY-2895
Added export format validation
2 parents 55ec990 + cead32e commit 42075d1

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ def prepare_export(
11901190
:param kwargs:
11911191
Arbitrary kwargs::
11921192
* integration_name: can be provided which will be used as a storage to store export file
1193-
* export_type: can be CSV for the Gen AI projects
1193+
* format: can be CSV for the Gen AI projects
11941194
11951195
:return: metadata object of the prepared export
11961196
:rtype: dict
@@ -1219,9 +1219,11 @@ def prepare_export(
12191219
else:
12201220
raise AppException("Integration not found.")
12211221
_export_type = None
1222-
export_type = kwargs.get("export_type")
1223-
if export_type and export_type == "csv":
1224-
_export_type = 3
1222+
export_type = kwargs.get("format")
1223+
if export_type:
1224+
export_type = export_type.lower()
1225+
if export_type == "csv":
1226+
_export_type = 3
12251227
response = self.controller.prepare_export(
12261228
project_name=project_name,
12271229
folder_names=folders,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ def execute(self):
12231223
)
12241224
self._response.data = (uploaded_score_names, skipped_score_names)
12251225
else:
1226-
self.reporter.warning_messages("Empty scores.")
1226+
self.reporter.warning_messages.append("Empty scores.")
12271227
return self._response
12281228

12291229

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ def validate_fuse(self):
7777
f"{ProjectType.get_name(self._project.type)} attached with URLs"
7878
)
7979

80+
def validate_export_type(self):
81+
if self._export_type == 2:
82+
if (
83+
self._project.type != ProjectType.VECTOR.value
84+
or self._project.upload_state != constances.UploadState.EXTERNAL.value
85+
):
86+
raise AppValidationException(
87+
"COCO format is not supported for this project."
88+
)
89+
elif self._export_type == 3 and self._project.type != ProjectType.GEN_AI.value:
90+
raise AppValidationException(
91+
"CSV format is not supported for this project."
92+
)
93+
8094
def validate_folder_names(self):
8195
if self._folder_names:
8296
condition = Condition("project_id", self._project.id, EQ)

tests/integration/test_upload_priority_scores.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from pathlib import Path
3+
from unittest import mock
34

45
from src.superannotate import SAClient
56
from tests.integration.base import BaseTestCase
@@ -17,6 +18,11 @@ class TestUploadPriorityScores(BaseTestCase):
1718
def folder_path(self):
1819
return os.path.join(Path(__file__).parent.parent, self.TEST_FOLDER_PATH)
1920

21+
def test_upload_empty_list(self):
22+
with self.assertLogs("sa", level="INFO") as cm:
23+
sa.upload_priority_scores(self.PROJECT_NAME, scores=[])
24+
assert cm.output[0] == 'INFO:sa:Uploading priority scores for 0 item(s) to TestUploadPriorityScores.'
25+
2026
def test_upload_priority_scores(self):
2127

2228
self._attach_items(count=4)

0 commit comments

Comments
 (0)