Skip to content

Commit 97541c3

Browse files
authored
Merge pull request #700 from superannotateai/develop
Develop
2 parents 6434a56 + f2219bf commit 97541c3

File tree

10 files changed

+75
-10
lines changed

10 files changed

+75
-10
lines changed

CHANGELOG.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,26 @@ History
66

77
All release highlights of this project will be documented in this file.
88

9+
4.4.23 - July 4, 2024
10+
_______________________
11+
12+
13+
**Updated**
14+
15+
- ``SAClient.prepare_export`` added the ability to export GenAI project data to a CSV file..
16+
17+
**Fiexed**
18+
19+
- ``SAClient.upload_priority_scores`` fixed an issue arising from empty arguments
20+
921
4.4.22 - Jun 13, 2024
1022
_______________________
1123

1224

1325
**Updated**
1426

1527
- Dependencies, updated ``packaging``, ``superannotate-schemas``.
16-
- ``search_folders`` by multiple statuses.
28+
- ``SAClient.search_folders`` by multiple statuses.
1729

1830

1931
4.4.21 - May 23, 2024
@@ -22,8 +34,8 @@ _______________________
2234

2335
**Updated**
2436

25-
- Dependencies, removed ``email-validator``.
26-
- ``add_items_to_subset`` added GenAI projects support.
37+
- Dependencies, removed ``SAClientemail-validator``.
38+
- ``SAClient.add_items_to_subset`` added GenAI projects support.
2739

2840

2941

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/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55

6-
__version__ = "4.4.22"
6+
__version__ = "4.4.23"
77

88
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
99

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,22 @@ 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+
* format: can be CSV for the Gen AI projects
1194+
1195+
Request Example:
1196+
::
1197+
client = SAClient()
1198+
1199+
export = client.prepare_export(
1200+
project = "Project Name",
1201+
folder_names = ["Folder 1", "Folder 2"],
1202+
annotation_statuses = ["Completed","QualityCheck"],
1203+
export_type = "CSV")
1204+
1205+
client.download_export("Project Name", export, "path_to_download")
11921206
11931207
:return: metadata object of the prepared export
11941208
:rtype: dict
@@ -1216,13 +1230,20 @@ def prepare_export(
12161230
break
12171231
else:
12181232
raise AppException("Integration not found.")
1233+
_export_type = None
1234+
export_type = kwargs.get("format")
1235+
if export_type:
1236+
export_type = export_type.lower()
1237+
if export_type == "csv":
1238+
_export_type = 3
12191239
response = self.controller.prepare_export(
12201240
project_name=project_name,
12211241
folder_names=folders,
12221242
include_fuse=include_fuse,
12231243
only_pinned=only_pinned,
12241244
annotation_statuses=annotation_statuses,
12251245
integration_id=integration_id,
1246+
export_type=_export_type,
12261247
)
12271248
if response.errors:
12281249
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/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: 20 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 (
@@ -75,6 +77,20 @@ def validate_fuse(self):
7577
f"{ProjectType.get_name(self._project.type)} attached with URLs"
7678
)
7779

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+
7894
def validate_folder_names(self):
7995
if self._folder_names:
8096
condition = Condition("project_id", self._project.id, EQ)
@@ -102,15 +118,17 @@ def execute(self):
102118
constances.AnnotationStatus.NOT_STARTED.name,
103119
constances.AnnotationStatus.SKIPPED.name,
104120
]
105-
106-
response = self._service_provider.prepare_export(
121+
kwargs = dict(
107122
project=self._project,
108123
folders=self._folder_names,
109124
annotation_statuses=self._annotation_statuses,
110125
include_fuse=self._include_fuse,
111126
only_pinned=self._only_pinned,
112127
integration_id=self._integration_id,
113128
)
129+
if self._export_type:
130+
kwargs["export_type"] = self._export_type
131+
response = self._service_provider.prepare_export(**kwargs)
114132
if not response.ok:
115133
raise AppException(response.error)
116134

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:

tests/integration/test_upload_priority_scores.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ class TestUploadPriorityScores(BaseTestCase):
1717
def folder_path(self):
1818
return os.path.join(Path(__file__).parent.parent, self.TEST_FOLDER_PATH)
1919

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

2230
self._attach_items(count=4)

0 commit comments

Comments
 (0)