Skip to content

Commit 18296b2

Browse files
authored
Merge pull request #593 from superannotateai/friday
Friday
2 parents 7f28f6f + 71adb21 commit 18296b2

34 files changed

+993
-605
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ on:
77
jobs:
88
build-n-publish:
99
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
10-
runs-on: ubuntu-18.04
10+
runs-on: ubuntu-20.04
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313
- name: Set up Python
14-
uses: actions/setup-python@v1
14+
uses: actions/setup-python@v4
1515
with:
16-
python-version: "3.7"
16+
python-version: "3.8"
1717
- name: Upgrade pip
1818
run: >-
1919
python -m

docs/source/api_reference/api_client.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Contents
99
:maxdepth: 8
1010

1111
api_project
12+
api_folder
1213
api_item
1314
api_annotation
1415
api_annotation_class
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=======
2+
Folders
3+
=======
4+
5+
.. automethod:: superannotate.SAClient.search_folders
6+
.. automethod:: superannotate.SAClient.assign_folder
7+
.. automethod:: superannotate.SAClient.unassign_folder
8+
.. automethod:: superannotate.SAClient.get_folder_by_id
9+
.. automethod:: superannotate.SAClient.get_folder_metadata
10+
.. automethod:: superannotate.SAClient.create_folder
11+
.. automethod:: superannotate.SAClient.delete_folders

docs/source/api_reference/api_image.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
==========
1+
======
22
Images
3-
==========
3+
======
44

55

66
.. _ref_search_images:
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
==========
1+
========
22
Projects
3-
==========
3+
========
44
.. _ref_projects:
55
.. _ref_search_projects:
6-
.. automethod:: superannotate.SAClient.search_projects
76
.. automethod:: superannotate.SAClient.create_project
7+
.. automethod:: superannotate.SAClient.search_projects
88
.. automethod:: superannotate.SAClient.create_project_from_metadata
99
.. automethod:: superannotate.SAClient.clone_project
10-
.. automethod:: superannotate.SAClient.delete_project
1110
.. automethod:: superannotate.SAClient.rename_project
11+
.. automethod:: superannotate.SAClient.delete_project
1212
.. _ref_get_project_metadata:
1313
.. automethod:: superannotate.SAClient.get_project_by_id
14+
.. automethod:: superannotate.SAClient.set_project_status
1415
.. automethod:: superannotate.SAClient.get_project_metadata
1516
.. automethod:: superannotate.SAClient.get_project_image_count
16-
.. automethod:: superannotate.SAClient.search_folders
17-
.. automethod:: superannotate.SAClient.assign_folder
18-
.. automethod:: superannotate.SAClient.unassign_folder
19-
.. automethod:: superannotate.SAClient.get_folder_by_id
20-
.. automethod:: superannotate.SAClient.get_folder_metadata
21-
.. automethod:: superannotate.SAClient.create_folder
22-
.. automethod:: superannotate.SAClient.delete_folders
2317
.. automethod:: superannotate.SAClient.upload_images_to_project
2418
.. automethod:: superannotate.SAClient.attach_items_from_integrated_storage
2519
.. automethod:: superannotate.SAClient.upload_image_to_project
@@ -30,5 +24,5 @@ Projects
3024
.. automethod:: superannotate.SAClient.add_contributors_to_project
3125
.. automethod:: superannotate.SAClient.get_project_settings
3226
.. automethod:: superannotate.SAClient.set_project_default_image_quality_in_editor
33-
.. automethod:: superannotate.SAClient.get_project_workflow
3427
.. automethod:: superannotate.SAClient.set_project_workflow
28+
.. automethod:: superannotate.SAClient.get_project_workflow

docs/source/api_reference/api_team.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
==========
1+
====
22
Team
3-
==========
3+
====
44

55

66
.. automethod:: superannotate.SAClient.get_team_metadata

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ mixpanel==4.8.3
1717
pydantic>=1.10.4
1818
setuptools>=57.4.0
1919
email-validator>=1.0.3
20-
nest-asyncio==1.5.4
2120
jsonschema==3.2.0
2221
pandas>=1.1.4
2322
aiofiles==0.8.0

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
import typing
55

6-
__version__ = "4.4.10b2"
6+
__version__ = "4.4.11dev2"
77

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

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import json
33
import os
4+
import platform
45
import sys
56
import typing
67
from inspect import signature
@@ -33,7 +34,7 @@ def __init__(self, token: TokenStr = None, config_path: str = None):
3334
if token:
3435
config = ConfigEntity(SA_TOKEN=token)
3536
elif config_path:
36-
config_path = Path(config_path)
37+
config_path = Path(config_path).expanduser()
3738
if not Path(config_path).is_file() or not os.access(
3839
config_path, os.R_OK
3940
):
@@ -124,10 +125,10 @@ def _retrieve_configs_from_env() -> typing.Union[ConfigEntity, None]:
124125
class Tracker:
125126
def get_mp_instance(self) -> Mixpanel:
126127
client = self.get_client()
127-
mp_token = "ca95ed96f80e8ec3be791e2d3097cf51"
128-
if client:
129-
if client.host != constants.BACKEND_URL:
130-
mp_token = "e741d4863e7e05b1a45833d01865ef0d"
128+
if client.controller._config.API_URL == constants.BACKEND_URL: # noqa
129+
mp_token = "ca95ed96f80e8ec3be791e2d3097cf51"
130+
else:
131+
mp_token = "e741d4863e7e05b1a45833d01865ef0d"
131132
return Mixpanel(mp_token)
132133

133134
@staticmethod
@@ -137,6 +138,8 @@ def get_default_payload(team_name, user_id):
137138
"Team": team_name,
138139
"Team Owner": user_id,
139140
"Version": __version__,
141+
"Python version": platform.python_version(),
142+
"Python interpreter type": platform.python_implementation(),
140143
}
141144

142145
def __init__(self, function):
@@ -170,6 +173,10 @@ def default_parser(function_name: str, kwargs: dict) -> tuple:
170173
for key, value in kwargs.items():
171174
if key == "self":
172175
continue
176+
elif key == "token":
177+
properties["sa_token"] = str(bool(value))
178+
elif key == "config_path":
179+
properties[key] = str(bool(value))
173180
elif value is None:
174181
properties[key] = value
175182
elif key == "project":
@@ -241,5 +248,6 @@ def __new__(mcs, name, bases, attrs):
241248
attr_value, FunctionType
242249
) and not attr_value.__name__.startswith("_"):
243250
attrs[attr_name] = Tracker(validate_arguments(attr_value))
251+
attrs["__init__"] = Tracker(validate_arguments(attrs["__init__"]))
244252
tmp = super().__new__(mcs, name, bases, attrs)
245253
return tmp

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

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import copy
33
import io
44
import json
5+
import logging
56
import os
67
import sys
78
import warnings
@@ -63,15 +64,15 @@
6364
from lib.core.types import Project
6465
from lib.infrastructure.utils import extract_project_folder
6566
from lib.infrastructure.validators import wrap_error
66-
import logging
67+
6768

6869
logger = logging.getLogger("sa")
6970

7071

7172
NotEmptyStr = TypeVar("NotEmptyStr", bound=constr(strict=True, min_length=1))
7273

7374

74-
PROJECT_STATUS = Literal["Undefined", "NotStarted", "InProgress", "Completed", "OnHold"]
75+
PROJECT_STATUS = Literal["NotStarted", "InProgress", "Completed", "OnHold"]
7576

7677
PROJECT_TYPE = Literal[
7778
"Vector", "Pixel", "Video", "Document", "Tiled", "Other", "PointCloud"
@@ -91,13 +92,7 @@
9192

9293
ANNOTATOR_ROLE = Literal["Admin", "Annotator", "QA"]
9394

94-
FOLDER_STATUS = Literal[
95-
"Undefined",
96-
"NotStarted",
97-
"InProgress",
98-
"Completed",
99-
"OnHold",
100-
]
95+
FOLDER_STATUS = Literal["NotStarted", "InProgress", "Completed", "OnHold"]
10196

10297

10398
class Setting(TypedDict):
@@ -782,6 +777,52 @@ def search_annotation_classes(
782777
for i in response.data
783778
]
784779

780+
def set_project_status(self, project: NotEmptyStr, status: PROJECT_STATUS):
781+
"""Set project status
782+
783+
:param project: project name
784+
:type project: str
785+
:param status: status to set, should be one of. \n
786+
♦ “NotStarted” \n
787+
♦ “InProgress” \n
788+
♦ “Completed” \n
789+
♦ “OnHold” \n
790+
:type status: str
791+
"""
792+
project = self.controller.get_project(name=project)
793+
project.status = constants.ProjectStatus.get_value(status)
794+
response = self.controller.projects.update(project)
795+
if response.errors:
796+
raise AppException(f"Failed to change {project.name} status.")
797+
logger.info(f"Successfully updated {project.name} status to {status}")
798+
799+
def set_folder_status(
800+
self, project: NotEmptyStr, folder: NotEmptyStr, status: FOLDER_STATUS
801+
):
802+
"""Set folder status
803+
804+
:param project: project name
805+
:type project: str
806+
:param folder: folder name
807+
:type folder: str
808+
:param status: status to set, should be one of. \n
809+
♦ “NotStarted” \n
810+
♦ “InProgress” \n
811+
♦ “Completed” \n
812+
♦ “OnHold” \n
813+
:type status: str
814+
"""
815+
project, folder = self.controller.get_project_folder(
816+
project_name=project, folder_name=folder
817+
)
818+
folder.status = constants.FolderStatus.get_value(status)
819+
response = self.controller.update(project, folder)
820+
if response.errors:
821+
raise AppException(f"Failed to change {project.name}/{folder.name} status.")
822+
logger.info(
823+
f"Successfully updated {project.name}/{folder.name} status to {status}"
824+
)
825+
785826
def set_project_default_image_quality_in_editor(
786827
self,
787828
project: Union[NotEmptyStr, dict],
@@ -1360,7 +1401,8 @@ def create_annotation_class(
13601401
:type color: str
13611402
13621403
:param attribute_groups: list of attribute group dicts.
1363-
The values for the "group_type" key are "radio"|"checklist"|"text"|"numeric".
1404+
The values for the "group_type" key are "radio"|"checklist"|"text"|"numeric"|"ocr".
1405+
"ocr "group_type" key is only available for Vector projects.
13641406
Mandatory keys for each attribute group are
13651407
13661408
- "name"
@@ -2340,7 +2382,7 @@ def query(
23402382
subset: Optional[NotEmptyStr] = None,
23412383
):
23422384
"""Return items that satisfy the given query.
2343-
Query syntax should be in SuperAnnotate query language(https://doc.superannotate.com/docs/query-search-1).
2385+
Query syntax should be in SuperAnnotate query language(https://doc.superannotate.com/docs/explore-overview).
23442386
23452387
:param project: project name or folder path (e.g., “project1/folder1”)
23462388
:type project: str

0 commit comments

Comments
 (0)