Skip to content

Commit a3b7457

Browse files
committed
Added export format validation
tod
1 parent aff1ac7 commit a3b7457

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

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

Lines changed: 8 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 and can be COCO for Vector projects
11941194
11951195
:return: metadata object of the prepared export
11961196
:rtype: dict
@@ -1219,9 +1219,13 @@ 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
1227+
elif export_type == "coco":
1228+
_export_type = 2
12251229
response = self.controller.prepare_export(
12261230
project_name=project_name,
12271231
folder_names=folders,

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)

0 commit comments

Comments
 (0)