Skip to content

Commit 6d0f898

Browse files
committed
Update version.py
1 parent 84165ea commit 6d0f898

File tree

9 files changed

+75
-68
lines changed

9 files changed

+75
-68
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ def __init__(self, token: str = None, config_path: str = None):
2626
version = os.environ.get("SA_VERSION", "v1")
2727
_token, _config_path = None, None
2828
_host = os.environ.get("SA_URL", constants.BACKEND_URL)
29-
_ssl_verify = not os.environ.get("SA_SSL", "True").lower() in ("false", "f", "0")
29+
_ssl_verify = not os.environ.get("SA_SSL", "True").lower() in (
30+
"false",
31+
"f",
32+
"0",
33+
)
3034
if token:
3135
_token = Controller.validate_token(token=token)
3236
elif config_path:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,7 +1943,7 @@ def search_models(
19431943
task: Optional[NotEmptyStr] = None,
19441944
include_global: Optional[StrictBool] = True,
19451945
):
1946-
"""Search for ML models.
1946+
r"""Search for ML models.
19471947
19481948
:param name: search string
19491949
:type name: str
@@ -2708,7 +2708,7 @@ def create_custom_fields(self, project: NotEmptyStr, fields: dict):
27082708
"""
27092709
project_name, _ = extract_project_folder(project)
27102710
response = self.controller.create_custom_schema(
2711-
project_name=project, schema=fields
2711+
project_name=project_name, schema=fields
27122712
)
27132713
if response.errors:
27142714
raise AppException(response.errors)
@@ -2753,7 +2753,7 @@ def get_custom_fields(self, project: NotEmptyStr):
27532753
}
27542754
"""
27552755
project_name, _ = extract_project_folder(project)
2756-
response = self.controller.get_custom_schema(project_name=project)
2756+
response = self.controller.get_custom_schema(project_name=project_name)
27572757
if response.errors:
27582758
raise AppException(response.errors)
27592759
return response.data

src/superannotate/lib/core/data_handlers.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
from typing import Callable
99
from typing import Dict
1010
from typing import List
11-
from operator import itemgetter
12-
13-
from superannotate_schemas.schemas.classes import AnnotationClass
14-
from superannotate_schemas.schemas.classes import Attribute
15-
from superannotate_schemas.schemas.classes import AttributeGroup
1611

1712
import lib.core as constances
1813
from lib.core.enums import AnnotationTypes
1914
from lib.core.reporter import Reporter
15+
from superannotate_schemas.schemas.classes import AnnotationClass
16+
from superannotate_schemas.schemas.classes import Attribute
17+
from superannotate_schemas.schemas.classes import AttributeGroup
2018

2119

2220
class BaseDataHandler(metaclass=ABCMeta):
@@ -49,7 +47,7 @@ def get_annotation_class(self, name: str) -> AnnotationClass:
4947

5048
@lru_cache()
5149
def get_attribute_group(
52-
self, annotation_class: AnnotationClass, attr_group_name: str
50+
self, annotation_class: AnnotationClass, attr_group_name: str
5351
) -> AttributeGroup:
5452
for attr_group in annotation_class.attribute_groups:
5553
if attr_group.name == attr_group_name:
@@ -116,10 +114,10 @@ def handle(self, annotation: dict):
116114

117115
class MissingIDsHandler(BaseAnnotationDateHandler):
118116
def __init__(
119-
self,
120-
annotation_classes: List[AnnotationClass],
121-
templates: List[dict],
122-
reporter: Reporter,
117+
self,
118+
annotation_classes: List[AnnotationClass],
119+
templates: List[dict],
120+
reporter: Reporter,
123121
):
124122
super().__init__(annotation_classes)
125123
self.validate_existing_classes(annotation_classes)
@@ -189,7 +187,7 @@ def handle(self, annotation: dict):
189187
template["name"]: template["id"] for template in self._templates
190188
}
191189
for annotation_instance in (
192-
i for i in annotation["instances"] if i.get("type", None) == "template"
190+
i for i in annotation["instances"] if i.get("type", None) == "template"
193191
):
194192
annotation_instance["templateId"] = template_name_id_map.get(
195193
annotation_instance.get("templateName", ""), -1
@@ -239,7 +237,13 @@ def handle(self, annotation: dict):
239237

240238

241239
class VideoFormatHandler(BaseAnnotationDateHandler):
242-
INSTANCE_FIELDS = {"pointLabels", "createdBy", "createdAt", "updatedBy", "updatedAt"}
240+
INSTANCE_FIELDS = {
241+
"pointLabels",
242+
"createdBy",
243+
"createdAt",
244+
"updatedBy",
245+
"updatedAt",
246+
}
243247

244248
@staticmethod
245249
def _point_handler(time_stamp):
@@ -270,7 +274,7 @@ def safe_time(timestamp):
270274
return "0" if str(timestamp) == "0.0" else timestamp
271275

272276
def convert_timestamp(timestamp):
273-
return timestamp / 10 ** 6 if timestamp else "0"
277+
return timestamp / 10**6 if timestamp else "0"
274278

275279
editor_data = {
276280
"instances": [],
@@ -368,10 +372,10 @@ def convert_timestamp(timestamp):
368372
(group_name, attr_name)
369373
)
370374
attributes_to_add = (
371-
existing_attributes_in_current_instance - active_attributes
375+
existing_attributes_in_current_instance - active_attributes
372376
)
373377
attributes_to_delete = (
374-
active_attributes - existing_attributes_in_current_instance
378+
active_attributes - existing_attributes_in_current_instance
375379
)
376380
if attributes_to_add or attributes_to_delete:
377381
editor_instance["timeline"][timestamp][

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

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
class CreateCustomSchemaUseCase(BaseReportableUseCase):
1313
def __init__(
14-
self,
15-
reporter: Reporter,
16-
project: ProjectEntity,
17-
schema: dict,
18-
backend_client: SuperannotateServiceProvider,
14+
self,
15+
reporter: Reporter,
16+
project: ProjectEntity,
17+
schema: dict,
18+
backend_client: SuperannotateServiceProvider,
1919
):
2020
super().__init__(reporter)
2121
self._project = project
@@ -43,10 +43,10 @@ def execute(self) -> Response:
4343

4444
class GetCustomSchemaUseCase(BaseReportableUseCase):
4545
def __init__(
46-
self,
47-
reporter: Reporter,
48-
project: ProjectEntity,
49-
backend_client: SuperannotateServiceProvider,
46+
self,
47+
reporter: Reporter,
48+
project: ProjectEntity,
49+
backend_client: SuperannotateServiceProvider,
5050
):
5151
super().__init__(reporter)
5252
self._project = project
@@ -66,11 +66,11 @@ def execute(self) -> Response:
6666

6767
class DeleteCustomSchemaUseCase(BaseReportableUseCase):
6868
def __init__(
69-
self,
70-
reporter: Reporter,
71-
project: ProjectEntity,
72-
fields: List[str],
73-
backend_client: SuperannotateServiceProvider,
69+
self,
70+
reporter: Reporter,
71+
project: ProjectEntity,
72+
fields: List[str],
73+
backend_client: SuperannotateServiceProvider,
7474
):
7575
super().__init__(reporter)
7676
self._project = project
@@ -84,7 +84,15 @@ def execute(self) -> Response:
8484
fields=self._fields,
8585
)
8686
if response.ok:
87-
self._response.data = response.data
87+
use_case_response = GetCustomSchemaUseCase(
88+
reporter=self.reporter,
89+
project=self._project,
90+
backend_client=self._backend_client,
91+
).execute()
92+
if use_case_response.errors:
93+
self._response.errors = use_case_response.errors
94+
else:
95+
self._response.data = use_case_response.data
8896
else:
8997
self._response.errors = response.error
9098
return self._response
@@ -94,12 +102,12 @@ class UploadCustomValuesUseCase(BaseReportableUseCase):
94102
CHUNK_SIZE = 5000
95103

96104
def __init__(
97-
self,
98-
reporter: Reporter,
99-
project: ProjectEntity,
100-
folder: FolderEntity,
101-
items: List[Dict[str, str]],
102-
backend_client: SuperannotateServiceProvider,
105+
self,
106+
reporter: Reporter,
107+
project: ProjectEntity,
108+
folder: FolderEntity,
109+
items: List[Dict[str, str]],
110+
backend_client: SuperannotateServiceProvider,
103111
):
104112
super().__init__(reporter)
105113
self._project = project
@@ -119,7 +127,7 @@ def execute(self) -> Response:
119127
project_id=self._project.id,
120128
team_id=self._project.team_id,
121129
folder_id=self._folder.uuid,
122-
items=self._items[idx: idx + self.CHUNK_SIZE], # noqa: E203
130+
items=self._items[idx : idx + self.CHUNK_SIZE], # noqa: E203
123131
)
124132
if not response.ok:
125133
self._response.errors = response.error
@@ -142,12 +150,12 @@ class DeleteCustomValuesUseCase(BaseReportableUseCase):
142150
CHUNK_SIZE = 5000
143151

144152
def __init__(
145-
self,
146-
reporter: Reporter,
147-
project: ProjectEntity,
148-
folder: FolderEntity,
149-
items: List[Dict[str, List[str]]],
150-
backend_client: SuperannotateServiceProvider,
153+
self,
154+
reporter: Reporter,
155+
project: ProjectEntity,
156+
folder: FolderEntity,
157+
items: List[Dict[str, List[str]]],
158+
backend_client: SuperannotateServiceProvider,
151159
):
152160
super().__init__(reporter)
153161
self._project = project
@@ -161,7 +169,7 @@ def execute(self) -> Response:
161169
project_id=self._project.id,
162170
team_id=self._project.team_id,
163171
folder_id=self._folder.uuid,
164-
items=self._items[idx: idx + self.CHUNK_SIZE], # noqa: E203
172+
items=self._items[idx : idx + self.CHUNK_SIZE], # noqa: E203
165173
)
166174
if not response.ok:
167175
self._response.errors = response.error

src/superannotate/lib/infrastructure/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def get_folder(self, query_string: str):
385385
query_items = query_string.split("&")
386386
params = {}
387387
for item in query_items:
388-
tmp = item.split('=')
388+
tmp = item.split("=")
389389
params[tmp[0]] = tmp[1]
390390

391391
response = self._request(get_folder_url, "get", params=params)

src/superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.4.1dev2"
1+
__version__ = "4.4.1dev5"

tests/integration/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from unittest import TestCase
22

33
from src.superannotate import SAClient
4-
4+
from tests import DATA_SET_PATH
55

66
sa = SAClient()
77

tests/integration/custom_fields/test_custom_schema.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ def test_create_schema(self):
2323
data = sa.create_custom_fields(self.PROJECT_NAME, self.PAYLOAD)
2424
self.assertEqual(self.PAYLOAD, data)
2525

26-
def test_(self):
27-
data = sa.create_custom_fields(self.PROJECT_NAME, {
28-
"test": {
29-
"type": "numbaaer"
30-
},
31-
"tester": {
32-
"type": "numbsser"
33-
}}
34-
)
35-
3626
def test_create_limit_25(self):
3727
payload = {i: {"type": "number"} for i in range(26)}
3828
with self.assertRaisesRegexp(
@@ -56,16 +46,18 @@ def test_delete_schema(self):
5646
payload = copy.copy(self.PAYLOAD)
5747
sa.create_custom_fields(self.PROJECT_NAME, payload)
5848
to_delete_field = list(payload.keys())[0]
59-
sa.delete_custom_fields(self.PROJECT_NAME, [to_delete_field])
49+
response = sa.delete_custom_fields(self.PROJECT_NAME, [to_delete_field])
6050
del payload[to_delete_field]
51+
assert response == payload
6152
self.assertEqual(sa.get_custom_fields(self.PROJECT_NAME), payload)
6253

6354
def test_upload_delete_custom_values(self):
6455
sa.create_custom_fields(self.PROJECT_NAME, self.PAYLOAD)
6556
item_name = "test"
6657
payload = {"test": 12}
6758
sa.attach_items(self.PROJECT_NAME, [{"name": item_name, "url": item_name}])
68-
sa.upload_custom_values(self.PROJECT_NAME, [{item_name: payload}] * 10000)
59+
response = sa.upload_custom_values(self.PROJECT_NAME, [{item_name: payload}] * 10000)
60+
assert response == {'failed': [], 'succeeded': {item_name}}
6961
data = sa.query(self.PROJECT_NAME, "metadata(status = NotStarted)")
7062
assert data[0]["custom_metadata"] == payload
7163
sa.delete_custom_values(self.PROJECT_NAME, [{item_name: ["test"]}])

tests/integration/items/test_saqul_query.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from pathlib import Path
33

44
from src.superannotate import SAClient
5-
from tests.integration.base import BaseTestCase
65
from tests import DATA_SET_PATH
6+
from tests.integration.base import BaseTestCase
77

88
sa = SAClient()
99

@@ -13,14 +13,13 @@ class TestEntitiesSearchVector(BaseTestCase):
1313
PROJECT_DESCRIPTION = "TestEntitiesSearchVector"
1414
PROJECT_TYPE = "Vector"
1515
FOLDER_NAME = "test_folder"
16-
TEST_FOLDER_PATH = "data_set/sample_project_vector"
16+
TEST_FOLDER_PATH = "sample_project_vector"
1717
TEST_QUERY = "instance(type =bbox )"
1818
TEST_INVALID_QUERY = "!instance(type =bbox )!"
1919

20-
2120
@property
2221
def folder_path(self):
23-
return os.path.join(Path(__file__).parent.parent, self.TEST_FOLDER_PATH)
22+
return os.path.join(DATA_SET_PATH, self.TEST_FOLDER_PATH)
2423

2524
def test_query(self):
2625
sa.create_folder(self.PROJECT_NAME, self.FOLDER_NAME)
@@ -40,7 +39,7 @@ def test_query(self):
4039

4140
try:
4241
self.assertRaises(
43-
Exception, sa.query(f"{self.PROJECT_NAME}/{self.FOLDER_NAME}", self.TEST_QUERY, subset="something")
42+
Exception, sa.query(f"{self.PROJECT_NAME}", self.TEST_QUERY, subset="something")
4443
)
4544
except Exception as e:
4645
self.assertEqual(

0 commit comments

Comments
 (0)