Skip to content

Commit aff1ac7

Browse files
committed
Added export csv format
1 parent 1d5eea6 commit aff1ac7

File tree

6 files changed

+22
-5
lines changed

6 files changed

+22
-5
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ minversion = 3.7
33
log_cli=true
44
python_files = test_*.py
55
;pytest_plugins = ['pytest_profiling']
6-
addopts = -n auto --dist=loadscope
6+
;addopts = -n auto --dist=loadscope
77

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,10 @@ def prepare_export(
11871187
:param only_pinned: enable only pinned output in export. This option disables all other types of output.
11881188
:type only_pinned: bool
11891189
1190-
:param kwargs: Arbitrary kwarg ``integration_name``
1191-
can be provided which will be used as a storage to store export file
1190+
:param kwargs:
1191+
Arbitrary kwargs::
1192+
* 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
11921194
11931195
:return: metadata object of the prepared export
11941196
:rtype: dict
@@ -1216,13 +1218,18 @@ def prepare_export(
12161218
break
12171219
else:
12181220
raise AppException("Integration not found.")
1221+
_export_type = None
1222+
export_type = kwargs.get("export_type")
1223+
if export_type and export_type == "csv":
1224+
_export_type = 3
12191225
response = self.controller.prepare_export(
12201226
project_name=project_name,
12211227
folder_names=folders,
12221228
include_fuse=include_fuse,
12231229
only_pinned=only_pinned,
12241230
annotation_statuses=annotation_statuses,
12251231
integration_id=integration_id,
1232+
export_type=_export_type,
12261233
)
12271234
if response.errors:
12281235
raise AppException(response.errors)

src/superannotate/lib/core/serviceproviders.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ def prepare_export(
571571
include_fuse: bool,
572572
only_pinned: bool,
573573
integration_id: int,
574+
export_type: int = None,
574575
) -> ServiceResponse:
575576
raise NotImplementedError
576577

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(
4646
only_pinned: bool,
4747
annotation_statuses: List[str] = None,
4848
integration_id: int = None,
49+
export_type: int = None,
4950
):
5051
super().__init__(),
5152
self._project = project
@@ -55,6 +56,7 @@ def __init__(
5556
self._include_fuse = include_fuse
5657
self._only_pinned = only_pinned
5758
self._integration_id = integration_id
59+
self._export_type = export_type
5860

5961
def validate_only_pinned(self):
6062
if (
@@ -102,15 +104,17 @@ def execute(self):
102104
constances.AnnotationStatus.NOT_STARTED.name,
103105
constances.AnnotationStatus.SKIPPED.name,
104106
]
105-
106-
response = self._service_provider.prepare_export(
107+
kwargs = dict(
107108
project=self._project,
108109
folders=self._folder_names,
109110
annotation_statuses=self._annotation_statuses,
110111
include_fuse=self._include_fuse,
111112
only_pinned=self._only_pinned,
112113
integration_id=self._integration_id,
113114
)
115+
if self._export_type:
116+
kwargs["export_type"] = self._export_type
117+
response = self._service_provider.prepare_export(**kwargs)
114118
if not response.ok:
115119
raise AppException(response.error)
116120

src/superannotate/lib/infrastructure/controller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,7 @@ def prepare_export(
10131013
only_pinned: bool,
10141014
annotation_statuses: List[str] = None,
10151015
integration_id: int = None,
1016+
export_type: int = None,
10161017
):
10171018
project = self.get_project(project_name)
10181019
use_case = usecases.PrepareExportUseCase(
@@ -1023,6 +1024,7 @@ def prepare_export(
10231024
only_pinned=only_pinned,
10241025
annotation_statuses=annotation_statuses,
10251026
integration_id=integration_id,
1027+
export_type=export_type,
10261028
)
10271029
return use_case.execute()
10281030

src/superannotate/lib/infrastructure/serviceprovider.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def prepare_export(
152152
include_fuse: bool,
153153
only_pinned: bool,
154154
integration_id: int = None,
155+
export_type: int = None,
155156
):
156157
annotation_statuses = ",".join(
157158
[str(constants.AnnotationStatus.get_value(i)) for i in annotation_statuses]
@@ -164,6 +165,8 @@ def prepare_export(
164165
"coco": 0,
165166
"time": datetime.datetime.now().strftime("%b %d %Y %H:%M"),
166167
}
168+
if export_type:
169+
data["export_format"] = export_type
167170
if folders:
168171
data["folder_names"] = folders
169172
if integration_id is not None:

0 commit comments

Comments
 (0)