Skip to content

Commit d163b06

Browse files
committed
Added approve/disapprove items
1 parent 32bc13d commit d163b06

File tree

17 files changed

+412
-140
lines changed

17 files changed

+412
-140
lines changed

docs/source/superannotate.sdk.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ ______
8181
.. automethod:: superannotate.SAClient.unassign_items
8282
.. automethod:: superannotate.SAClient.get_item_metadata
8383
.. automethod:: superannotate.SAClient.set_annotation_statuses
84+
.. automethod:: superannotate.SAClient.set_approval_statuses
85+
.. automethod:: superannotate.SAClient.set_approval
8486

8587
----------
8688

pytest.ini

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

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ xmltodict==0.12.0
1010
opencv-python>=4.4.0.42
1111
wheel==0.35.1
1212
packaging>=20.4
13-
plotly==4.1.0
13+
plotly>=4.1.0
1414
ffmpeg-python>=0.2.0
1515
fire==0.4.0
1616
mixpanel==4.8.3

src/superannotate/__init__.py

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

5-
__version__ = "4.4.9dev2"
5+
__version__ = "4.4.9dev4"
66

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

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

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from lib.app.interface.types import AnnotationStatuses
2424
from lib.app.interface.types import AnnotationType
2525
from lib.app.interface.types import AnnotatorRole
26+
from lib.app.interface.types import ApprovalStatuses
2627
from lib.app.interface.types import AttachmentArg
2728
from lib.app.interface.types import AttachmentDict
2829
from lib.app.interface.types import ClassType
@@ -2332,7 +2333,7 @@ def search_items(
23322333
♦ “QualityCheck” \n
23332334
♦ “Returned” \n
23342335
♦ “Completed” \n
2335-
♦ “Skippe
2336+
♦ “Skip” \n
23362337
:type annotation_status: str
23372338
23382339
:param annotator_email: returns those items’ names that are assigned to the specified annotator.
@@ -2569,13 +2570,13 @@ def set_annotation_statuses(
25692570
:param project: project name or folder path (e.g., “project1/folder1”).
25702571
:type project: str
25712572
2572-
:param annotation_status: annotation status to set, should be one of.
2573-
“NotStarted”
2574-
“InProgress”
2575-
“QualityCheck”
2576-
“Returned”
2577-
“Completed”
2578-
“Skipped”
2573+
:param annotation_status: annotation status to set, should be one of. \n
2574+
“NotStarted” \n
2575+
“InProgress” \n
2576+
“QualityCheck” \n
2577+
“Returned” \n
2578+
“Completed” \n
2579+
“Skipped” \n
25792580
:type annotation_status: str
25802581
25812582
:param items: item names to set the mentioned status for. If None, all the items in the project will be used.
@@ -3021,3 +3022,32 @@ def add_items_to_subset(
30213022

30223023
return response.data
30233024

3025+
def set_approval_statuses(
3026+
self,
3027+
project: NotEmptyStr,
3028+
approval_status: Union[ApprovalStatuses, None],
3029+
items: Optional[List[NotEmptyStr]] = None,
3030+
):
3031+
"""Sets annotation statuses of items
3032+
3033+
:param project: project name or folder path (e.g., “project1/folder1”).
3034+
:type project: str
3035+
3036+
:param approval_status: approval status to set, should be one of. \n
3037+
♦ None \n
3038+
♦ “Approved” \n
3039+
♦ “Disapproved” \n
3040+
:type approval_status: str
3041+
3042+
:param items: item names to set the mentioned status for. If None, all the items in the project will be used.
3043+
:type items: list of strs
3044+
"""
3045+
project, folder = self.controller.get_project_folder_by_path(project)
3046+
response = self.controller.items.set_approval_statuses(
3047+
project=project,
3048+
folder=folder,
3049+
approval_status=approval_status,
3050+
item_names=items,
3051+
)
3052+
if response.errors:
3053+
raise AppException(response.errors)

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Union
66

77
from lib.core.enums import AnnotationStatus
8+
from lib.core.enums import ApprovalStatus
89
from lib.core.enums import BaseTitledEnum
910
from lib.core.enums import ClassTypeEnum
1011
from lib.core.enums import FolderStatus
@@ -199,6 +200,22 @@ def validate(cls, value: Union[str]) -> Union[str]:
199200
return value
200201

201202

203+
class ApprovalStatuses(StrictStr):
204+
@classmethod
205+
def validate(cls, value: Union[str]) -> Union[str]:
206+
if value is None:
207+
return value
208+
if value.lower() not in ApprovalStatus.values() or not isinstance(value, str):
209+
raise TypeError(
210+
f"Available approval_status options are {', '.join(map(str, ApprovalStatus.titles()))}."
211+
)
212+
return value
213+
214+
@classmethod
215+
def __get_validators__(cls):
216+
yield cls.validate
217+
218+
202219
def validate_arguments(func):
203220
@wraps(func)
204221
def wrapped(self, *args, **kwargs):

src/superannotate/lib/app/server/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Usage
1010

1111
.. code-block:: bash
1212
13-
./run.sh --token=<your team token>
13+
./run.sh --token=<your team token>

src/superannotate/lib/core/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from superannotate.lib.core.config import Config
44
from superannotate.lib.core.enums import AnnotationStatus
5+
from superannotate.lib.core.enums import ApprovalStatus
56
from superannotate.lib.core.enums import FolderStatus
67
from superannotate.lib.core.enums import ImageQuality
78
from superannotate.lib.core.enums import ProjectStatus
@@ -16,7 +17,7 @@
1617
CONFIG_PATH = "~/.superannotate/config.json"
1718
CONFIG_FILE_LOCATION = expanduser(CONFIG_PATH)
1819
LOG_FILE_LOCATION = expanduser("~/.superannotate")
19-
BACKEND_URL = "https://api.annotate.online"
20+
BACKEND_URL = "https://api.superannotate.com"
2021

2122
DEFAULT_IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "tif", "tiff", "webp", "bmp"]
2223
DEFAULT_FILE_EXCLUDE_PATTERNS = ["___save.png", "___fuse.png"]
@@ -121,6 +122,7 @@
121122
SegmentationStatus,
122123
ImageQuality,
123124
AnnotationStatus,
125+
ApprovalStatus,
124126
CONFIG_FILE_LOCATION,
125127
CONFIG_PATH,
126128
BACKEND_URL,

src/superannotate/lib/core/enums.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __get__(self, instance, owner):
1212

1313
class BaseTitledEnum(int, Enum):
1414
def __new__(cls, title, value):
15-
obj = int.__new__(cls, value)
15+
obj = super().__new__(cls, value)
1616
obj._value_ = value
1717
obj.__doc__ = title
1818
obj._type = "titled_enum"
@@ -40,15 +40,15 @@ def get_name(cls, value):
4040
@classmethod
4141
def get_value(cls, name):
4242
for enum in list(cls):
43-
if enum.__doc__.lower() == name.lower():
43+
if enum.__doc__ and name and enum.__doc__.lower() == name.lower():
4444
if isinstance(enum.value, int):
4545
if enum.value < 0:
4646
return ""
4747
return enum.value
4848

4949
@classmethod
5050
def values(cls):
51-
return [enum.__doc__.lower() for enum in list(cls)]
51+
return [enum.__doc__.lower() if enum else None for enum in list(cls)]
5252

5353
@classmethod
5454
def titles(cls):
@@ -64,6 +64,12 @@ def __hash__(self):
6464
return hash(self.name)
6565

6666

67+
class ApprovalStatus(BaseTitledEnum):
68+
NONE = None, 0
69+
DISAPPROVED = "Disapproved", 1
70+
APPROVED = "Approved", 2
71+
72+
6773
class AnnotationTypes(str, Enum):
6874
BBOX = "bbox"
6975
EVENT = "event"
@@ -170,9 +176,3 @@ class SegmentationStatus(BaseTitledEnum):
170176
IN_PROGRESS = "InProgress", 2
171177
COMPLETED = "Completed", 3
172178
FAILED = "Failed", 4
173-
174-
175-
class ApprovalStatus(BaseTitledEnum):
176-
NONE = None, 0
177-
DISAPPROVED = "disapproved", 1
178-
APPROVED = "approved", 2

src/superannotate/lib/core/serviceproviders.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,16 @@ def set_statuses(
293293
) -> ServiceResponse:
294294
raise NotImplementedError
295295

296+
@abstractmethod
297+
def set_approval_statuses(
298+
self,
299+
project: entities.ProjectEntity,
300+
folder: entities.FolderEntity,
301+
item_names: List[str],
302+
approval_status: int,
303+
) -> ServiceResponse:
304+
raise NotImplementedError
305+
296306
@abstractmethod
297307
def delete_multiple(
298308
self, project: entities.ProjectEntity, item_ids: List[int]

0 commit comments

Comments
 (0)