Skip to content

Commit 8ef2f83

Browse files
committed
Update export statuses
1 parent 6ccd0bc commit 8ef2f83

File tree

9 files changed

+21
-51
lines changed

9 files changed

+21
-51
lines changed

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@
8282
"GenAI",
8383
]
8484

85-
ANNOTATION_STATUS = Literal[
86-
"NotStarted", "InProgress", "QualityCheck", "Returned", "Completed", "Skipped"
87-
]
8885

8986
APPROVAL_STATUS = Literal["Approved", "Disapproved", None]
9087

@@ -1193,7 +1190,7 @@ def prepare_export(
11931190
self,
11941191
project: Union[NotEmptyStr, dict],
11951192
folder_names: Optional[List[NotEmptyStr]] = None,
1196-
annotation_statuses: Optional[List[ANNOTATION_STATUS]] = None,
1193+
annotation_statuses: Optional[List[str]] = None,
11971194
include_fuse: Optional[bool] = False,
11981195
only_pinned=False,
11991196
**kwargs,
@@ -1245,15 +1242,6 @@ def prepare_export(
12451242
folders = [folder_name] if folder_name else []
12461243
else:
12471244
folders = folder_names
1248-
if not annotation_statuses:
1249-
annotation_statuses = [
1250-
constants.AnnotationStatus.NOT_STARTED.name,
1251-
constants.AnnotationStatus.IN_PROGRESS.name,
1252-
constants.AnnotationStatus.QUALITY_CHECK.name,
1253-
constants.AnnotationStatus.RETURNED.name,
1254-
constants.AnnotationStatus.COMPLETED.name,
1255-
constants.AnnotationStatus.SKIPPED.name,
1256-
]
12571245
integration_name = kwargs.get("integration_name")
12581246
integration_id = None
12591247
if integration_name:
@@ -2125,7 +2113,7 @@ def upload_images_to_project(
21252113
self,
21262114
project: NotEmptyStr,
21272115
img_paths: List[NotEmptyStr],
2128-
annotation_status: Optional[ANNOTATION_STATUS] = "NotStarted",
2116+
annotation_status: str = "NotStarted",
21292117
from_s3_bucket=None,
21302118
image_quality_in_editor: Optional[IMAGE_QUALITY] = None,
21312119
):
@@ -2556,7 +2544,7 @@ def search_items(
25562544
self,
25572545
project: NotEmptyStr,
25582546
name_contains: NotEmptyStr = None,
2559-
annotation_status: Optional[ANNOTATION_STATUS] = None,
2547+
annotation_status: str = None,
25602548
annotator_email: Optional[NotEmptyStr] = None,
25612549
qa_email: Optional[NotEmptyStr] = None,
25622550
recursive: bool = False,
@@ -3021,7 +3009,7 @@ def move_items(
30213009
def set_annotation_statuses(
30223010
self,
30233011
project: Union[NotEmptyStr, dict],
3024-
annotation_status: ANNOTATION_STATUS,
3012+
annotation_status: NotEmptyStr,
30253013
items: Optional[List[NotEmptyStr]] = None,
30263014
):
30273015
"""Sets annotation statuses of items

src/superannotate/lib/core/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from os.path import expanduser
66

77
from lib.core.config import Config
8-
from lib.core.enums import AnnotationStatus
98
from lib.core.enums import ApprovalStatus
109
from lib.core.enums import FolderStatus
1110
from lib.core.enums import ImageQuality
@@ -189,7 +188,6 @@ def setup_logging(level=DEFAULT_LOGGING_LEVEL, file_path=LOG_FILE_LOCATION):
189188
UploadState,
190189
TrainingStatus,
191190
ImageQuality,
192-
AnnotationStatus,
193191
ApprovalStatus,
194192
CONFIG_JSON_FILE_LOCATION,
195193
CONFIG_INI_FILE_LOCATION,

src/superannotate/lib/core/enums.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,6 @@ class ExportStatus(BaseTitledEnum):
156156
ERROR = "error", 4
157157

158158

159-
class AnnotationStatus(BaseTitledEnum):
160-
NOT_STARTED = "NotStarted", 1
161-
IN_PROGRESS = "InProgress", 2
162-
QUALITY_CHECK = "QualityCheck", 3
163-
RETURNED = "Returned", 4
164-
COMPLETED = "Completed", 5
165-
SKIPPED = "Skipped", 6
166-
167-
168159
class ClassTypeEnum(BaseTitledEnum):
169160
OBJECT = "object", 1
170161
TAG = "tag", 2

src/superannotate/lib/core/jsx_conditions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import urllib.parse
12
from abc import abstractmethod
23
from enum import Enum
34
from typing import Any
@@ -55,9 +56,9 @@ def __init__(self, key: str, value: Any, operator: OperatorEnum):
5556

5657
def _build(self):
5758
if isinstance(self._value, (list, set, tuple)):
58-
return f"{self._key}||{self._operator.value}||{','.join(map(str, self._value))}"
59+
return f"{self._key}||{self._operator.value}||{','.join(map(urllib.parse.quote, map(str, self._value)))}"
5960
else:
60-
return f"{self._key}||{self._operator.value}||{self._value}"
61+
return f"{self._key}||{self._operator.value}||{urllib.parse.quote(str(self._value))}"
6162

6263
def build(self) -> str:
6364
return f"filter={self._build()}"

src/superannotate/lib/core/serviceproviders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,10 @@ def prepare_export(
584584
self,
585585
project: entities.ProjectEntity,
586586
folders: List[str],
587-
annotation_statuses: List[str],
588587
include_fuse: bool,
589588
only_pinned: bool,
590589
integration_id: int,
590+
annotation_statuses: List[str] = None,
591591
export_type: int = None,
592592
) -> ServiceResponse:
593593
raise NotImplementedError

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,17 +546,15 @@ def __init__(
546546
reporter: Reporter,
547547
project: ProjectEntity,
548548
folder: FolderEntity,
549-
annotation_status: str,
549+
annotation_status: int,
550550
service_provider: BaseServiceProvider,
551551
item_names: List[str] = None,
552552
):
553553
super().__init__(reporter)
554554
self._project = project
555555
self._folder = folder
556556
self._item_names = item_names
557-
self._annotation_status_code = constants.AnnotationStatus(
558-
annotation_status
559-
).value
557+
self._annotation_status_code = annotation_status
560558
self._service_provider = service_provider
561559

562560
def validate_items(self):

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,15 @@ def execute(self):
104104
if self.is_valid():
105105
if self._project.upload_state == constances.UploadState.EXTERNAL.value:
106106
self._include_fuse = False
107-
108-
if not self._annotation_statuses:
109-
self._annotation_statuses = [
110-
constances.AnnotationStatus.IN_PROGRESS.name,
111-
constances.AnnotationStatus.COMPLETED.name,
112-
constances.AnnotationStatus.QUALITY_CHECK.name,
113-
constances.AnnotationStatus.RETURNED.name,
114-
constances.AnnotationStatus.NOT_STARTED.name,
115-
constances.AnnotationStatus.SKIPPED.name,
116-
]
117107
kwargs = dict(
118108
project=self._project,
119109
folders=self._folder_names,
120-
annotation_statuses=self._annotation_statuses,
121110
include_fuse=self._include_fuse,
122111
only_pinned=self._only_pinned,
123112
integration_id=self._integration_id,
124113
)
114+
if self._annotation_statuses:
115+
kwargs["annotation_statuses"] = (self._annotation_statuses,)
125116
if self._export_type:
126117
kwargs["export_type"] = self._export_type
127118
response = self._service_provider.prepare_export(**kwargs)

src/superannotate/lib/infrastructure/serviceprovider.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,23 +190,26 @@ def prepare_export(
190190
self,
191191
project: entities.ProjectEntity,
192192
folders: List[str],
193-
annotation_statuses: List[str],
194193
include_fuse: bool,
195194
only_pinned: bool,
195+
annotation_statuses: List[str] = None,
196196
integration_id: int = None,
197197
export_type: int = None,
198198
):
199-
annotation_statuses = ",".join(
200-
[str(constants.AnnotationStatus(i).value) for i in annotation_statuses]
201-
)
202199

203200
data = {
204-
"include": annotation_statuses,
205201
"fuse": int(include_fuse),
206202
"is_pinned": int(only_pinned),
207203
"coco": 0,
208204
"time": datetime.datetime.now().strftime("%b %d %Y %H:%M"),
209205
}
206+
if annotation_statuses:
207+
data["include"] = ",".join(
208+
[
209+
str(self.get_annotation_status_value(project, i))
210+
for i in annotation_statuses
211+
]
212+
)
210213
if export_type:
211214
data["export_format"] = export_type
212215
if folders:

tests/unit/test_jsx_conditions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ def test_multiple_query_build(self):
1717
)
1818
query &= Join("metadata") & Join("fields", ["field1", "field2"])
1919
self.assertEquals(
20-
"filter=id||$in||1,2,3&or=id||$eq||2&join=metadata&join=fields||field1,field2",
20+
"filter=id||$in||1%2C2%2C3&or=id||$eq||2&join=metadata&join=fields||field1,field2",
2121
query.build_query(),
2222
)

0 commit comments

Comments
 (0)