Skip to content

Commit d6573e1

Browse files
authored
Merge branch 'friday' into 1708_implimentation
2 parents 2f40c6a + 9402ba2 commit d6573e1

File tree

10 files changed

+65
-12
lines changed

10 files changed

+65
-12
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ repos:
3636
- id: check-byte-order-marker
3737
- id: trailing-whitespace
3838
- id: end-of-file-fixer
39-
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
40-
rev: '' # pick a git hash / tag to point to
41-
hooks:
42-
- id: editorconfig-checker
43-
alias: ec
4439
# - repo: 'https://github.com/asottile/dead'
4540
# rev: v1.3.0
4641
# hooks:

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ 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

src/superannotate/lib/app/analytics/aggregators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ def aggregate_annotations_as_df(self):
214214
return self.aggregate_video_annotations_as_df(annotation_paths)
215215
elif self.project_type is constances.ProjectType.DOCUMENT:
216216
return self.aggregate_document_annotations_as_df(annotation_paths)
217+
else:
218+
raise AppException(
219+
f"The function is not supported for {self.project_type.name} projects."
220+
)
217221

218222
def __add_attributes_to_raws(self, raws, attributes, element_raw):
219223
for attribute_id, attribute in enumerate(attributes):

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from typing_extensions import Literal
2020

2121
if sys.version_info < (3, 11):
22-
from typing_extensions import TypedDict, NotRequired # noqa
22+
from typing_extensions import TypedDict, NotRequired, Required # noqa
2323
else:
24-
from typing import TypedDict, NotRequired # noqa
24+
from typing import TypedDict, NotRequired, Required # noqa
2525

2626
import boto3
2727
from pydantic import StrictBool
@@ -111,7 +111,7 @@ class PriorityScore(TypedDict):
111111

112112

113113
class Attachment(TypedDict, total=False):
114-
url: str
114+
url: Required[str] # noqa
115115
name: NotRequired[str] # noqa
116116

117117

@@ -2022,8 +2022,8 @@ def upload_images_to_project(
20222022
return uploaded, failed_images, duplications
20232023
raise AppException(use_case.response.errors)
20242024

2025-
@staticmethod
20262025
def aggregate_annotations_as_df(
2026+
self,
20272027
project_root: Union[NotEmptyStr, Path],
20282028
project_type: PROJECT_TYPE,
20292029
folder_names: Optional[List[Union[Path, NotEmptyStr]]] = None,

src/superannotate/lib/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def setup_logging(level=DEFAULT_LOGGING_LEVEL, file_path=LOG_FILE_LOCATION):
3535
global _loggers
3636
if not _loggers.get("sa"):
3737
logger = logging.getLogger("sa")
38-
logger.propagate = False
38+
logger.propagate = True
3939
logger.setLevel(level)
4040
stream_handler = logging.StreamHandler()
4141
formatter = Formatter("SA-PYTHON-SDK - %(levelname)s - %(message)s")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"id":1115467,"project_id":79598,"name":"tag_class","color":"#A613DA","type":"tag","createdAt":"2022-03-31T08:38:07.000Z","updatedAt":"2022-08-22T06:51:36.000Z","attribute_groups":[{"group_type":"radio","id":391880,"class_id":1115467,"name":"group_single","createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z","attributes":[{"id":1710830,"group_id":391880,"project_id":79598,"name":"single_atr1","count":0,"createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z"},{"id":1710831,"group_id":391880,"project_id":79598,"name":"single_atr2","count":0,"createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z"},{"id":1710832,"group_id":391880,"project_id":79598,"name":"single_atr3","count":0,"createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z"}],"default_value":null},{"group_type":"checklist","id":391881,"class_id":1115467,"name":"group_multi","createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z","attributes":[{"id":1710833,"group_id":391881,"project_id":79598,"name":"multi_atr1","count":0,"createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z"},{"id":1710834,"group_id":391881,"project_id":79598,"name":"multi_atr2","count":0,"createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z"},{"id":1710835,"group_id":391881,"project_id":79598,"name":"multi_atr3","count":0,"createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z"}],"default_value":[]},{"group_type":"numeric","id":391882,"class_id":1115467,"name":"group_numeric","createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z","attributes":[]},{"group_type":"text","id":391883,"class_id":1115467,"name":"group_text","createdAt":"2022-08-22T06:51:36.000Z","updatedAt":"2022-08-22T06:51:36.000Z","attributes":[]}]},{"id":1115466,"project_id":79598,"name":"car","color":"#74F950","type":"object","createdAt":"2022-03-31T08:38:07.000Z","updatedAt":"2022-03-31T08:38:07.000Z","attribute_groups":[]},{"id":1115465,"project_id":79598,"name":"tree","color":"#045D6B","type":"object","createdAt":"2022-03-31T08:38:07.000Z","updatedAt":"2022-03-31T08:38:07.000Z","attribute_groups":[]},{"id":1115464,"project_id":79598,"name":"animal","color":"#D5562D","type":"object","createdAt":"2022-03-31T08:38:07.000Z","updatedAt":"2022-08-22T06:53:18.000Z","attribute_groups":[{"group_type":"radio","id":391884,"class_id":1115464,"name":"gr_single","createdAt":"2022-08-22T06:53:18.000Z","updatedAt":"2022-08-22T06:53:18.000Z","attributes":[{"id":1710846,"group_id":391884,"project_id":79598,"name":"atr_sng1","count":0,"createdAt":"2022-08-22T06:53:19.000Z","updatedAt":"2022-08-22T06:53:19.000Z"},{"id":1710847,"group_id":391884,"project_id":79598,"name":"atr_sng2","count":0,"createdAt":"2022-08-22T06:53:19.000Z","updatedAt":"2022-08-22T06:53:19.000Z"},{"id":1710848,"group_id":391884,"project_id":79598,"name":"atr_sng3","count":0,"createdAt":"2022-08-22T06:53:19.000Z","updatedAt":"2022-08-22T06:53:19.000Z"}],"default_value":"atr_sng1"},{"group_type":"checklist","id":391885,"class_id":1115464,"name":"gr_multi","createdAt":"2022-08-22T06:53:18.000Z","updatedAt":"2022-08-22T06:53:18.000Z","attributes":[{"id":1710849,"group_id":391885,"project_id":79598,"name":"atr_mlt1","count":0,"createdAt":"2022-08-22T06:53:19.000Z","updatedAt":"2022-08-22T06:53:19.000Z"},{"id":1710850,"group_id":391885,"project_id":79598,"name":"atr_mlt2","count":0,"createdAt":"2022-08-22T06:53:19.000Z","updatedAt":"2022-08-22T06:53:19.000Z"},{"id":1710851,"group_id":391885,"project_id":79598,"name":"atr_mlt3","count":0,"createdAt":"2022-08-22T06:53:19.000Z","updatedAt":"2022-08-22T06:53:19.000Z"}],"default_value":["atr_mlt2","atr_mlt3"]},{"group_type":"text","id":391886,"class_id":1115464,"name":"gr_txt","createdAt":"2022-08-22T06:53:18.000Z","updatedAt":"2022-08-22T06:53:18.000Z","attributes":[]},{"group_type":"numeric","id":391887,"class_id":1115464,"name":"gr_num","createdAt":"2022-08-22T06:53:18.000Z","updatedAt":"2022-08-22T06:53:18.000Z","attributes":[]}]},{"id":1115463,"project_id":79598,"name":"human","color":"#582E8F","type":"object","createdAt":"2022-03-31T08:38:07.000Z","updatedAt":"2022-03-31T08:38:07.000Z","attribute_groups":[{"group_type":"radio","id":279400,"class_id":1115463,"name":"human_group","createdAt":"2022-03-31T08:38:07.000Z","updatedAt":"2022-03-31T08:38:07.000Z","attributes":[{"id":1334310,"group_id":279400,"project_id":79598,"name":"human_atr1","count":0,"createdAt":"2022-03-31T08:38:07.000Z","updatedAt":"2022-03-31T08:38:07.000Z"},{"id":1334311,"group_id":279400,"project_id":79598,"name":"human_atr2","count":0,"createdAt":"2022-03-31T08:38:07.000Z","updatedAt":"2022-03-31T08:38:07.000Z"}],"default_value":null}]}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"metadata":{"height":3840,"width":5760,"name":"file_example.jpg","lastAction":{"email":"arturn@superannotate.com","timestamp":1676214999521},"projectId":79598,"isPredicted":false,"status":"InProgress","pinned":false,"annotatorEmail":"automation_sa@mailinator.com","qaEmail":null},"instances":[{"type":"bbox","classId":1115463,"probability":100,"points":{"x1":4104.16,"x2":5598.13,"y1":2699.6,"y2":3470.08},"groupId":0,"pointLabels":{"0":"point1","2":"point3"},"locked":false,"attributes":[],"trackingId":null,"error":null,"createdAt":"2022-04-04T11:49:22.636Z","createdBy":{"email":"arturn@superannotate.com","role":"Admin"},"creationType":"Manual","updatedAt":"2023-02-12T15:01:57.999Z","updatedBy":{"email":"arturn@superannotate.com","role":"Admin"},"className":"human"},{"type":"polygon","classId":1115465,"probability":100,"points":[3015.3,1275.7,2770.47,457.45,3414.77,393.02,3840,1533.42,3421.21,1552.75,3182.82,1391.68],"exclude":[],"groupId":0,"pointLabels":{},"locked":true,"attributes":[],"trackingId":null,"error":null,"createdAt":"2022-08-22T06:56:12.069Z","createdBy":{"email":"arturn@superannotate.com","role":"Admin"},"creationType":"Manual","updatedAt":"2022-08-22T06:56:50.652Z","updatedBy":{"email":"arturn@superannotate.com","role":"Admin"},"className":"tree"},{"type":"polyline","classId":1115465,"probability":100,"points":[412.35,2718.93,1211.28,3466.31],"groupId":0,"pointLabels":{},"locked":false,"attributes":[],"trackingId":null,"error":null,"createdAt":"2022-08-22T06:57:17.116Z","createdBy":{"email":"arturn@superannotate.com","role":"Admin"},"creationType":"Manual","updatedAt":"2022-08-22T06:57:17.116Z","updatedBy":{"email":"arturn@superannotate.com","role":"Admin"},"className":"tree"},{"type":"ellipse","classId":1115466,"probability":100,"cx":1659.06,"cy":2245.37,"rx":853.69,"ry":840.8,"angle":0,"groupId":0,"pointLabels":{},"locked":false,"attributes":[],"trackingId":null,"error":null,"createdAt":"2022-08-22T06:57:46.016Z","createdBy":{"email":"arturn@superannotate.com","role":"Admin"},"creationType":"Manual","updatedAt":"2022-08-22T06:57:46.016Z","updatedBy":{"email":"arturn@superannotate.com","role":"Admin"},"className":"car"},{"type":"point","classId":1115464,"probability":100,"x":960,"y":676.51,"groupId":0,"pointLabels":{},"locked":false,"attributes":[{"id":1710850,"groupId":391885,"name":"atr_mlt2","groupName":"gr_multi"}],"trackingId":null,"error":null,"createdAt":"2022-08-22T06:58:00.668Z","createdBy":{"email":"arturn@superannotate.com","role":"Admin"},"creationType":"Manual","updatedAt":"2022-08-22T07:00:20.210Z","updatedBy":{"email":"arturn@superannotate.com","role":"Admin"},"className":"animal"},{"type":"rbbox","classId":1115464,"probability":100,"points":{"x1":3723.71,"y1":513.84,"x2":4458.83,"y2":255.21,"x3":4773.48,"y3":1149.59,"x4":4038.36,"y4":1408.22},"groupId":0,"pointLabels":{},"locked":false,"attributes":[],"trackingId":null,"error":null,"createdAt":"2022-08-22T06:58:27.367Z","createdBy":{"email":"arturn@superannotate.com","role":"Admin"},"creationType":"Manual","updatedAt":"2022-08-22T07:00:43.136Z","updatedBy":{"email":"arturn@superannotate.com","role":"Admin"},"className":"animal"},{"type":"cuboid","classId":1115464,"probability":100,"points":{"f1":{"x":2467.65,"y":2847.79},"f2":{"x":3775.57,"y":3021.74},"r1":{"x":2177.72,"y":3311.69},"r2":{"x":3485.64,"y":3485.64}},"groupId":0,"pointLabels":{},"locked":false,"attributes":[{"id":1710846,"groupId":391884,"name":"atr_sng1","groupName":"gr_single"},{"id":1710850,"groupId":391885,"name":"atr_mlt2","groupName":"gr_multi"},{"id":1710851,"groupId":391885,"name":"atr_mlt3","groupName":"gr_multi"},{"groupId":391886,"name":"text","groupName":"gr_txt"},{"groupId":391887,"name":3,"groupName":"gr_num"}],"trackingId":null,"error":null,"createdAt":"2022-08-22T06:59:05.288Z","createdBy":{"email":"arturn@superannotate.com","role":"Admin"},"creationType":"Manual","updatedAt":"2022-08-22T06:59:42.086Z","updatedBy":{"email":"arturn@superannotate.com","role":"Admin"},"className":"animal"},{"type":"tag","classId":1115467,"probability":100,"attributes":[{"id":1710830,"groupId":391880,"name":"single_atr1","groupName":"group_single"},{"id":1710835,"groupId":391881,"name":"multi_atr3","groupName":"group_multi"},{"id":1710834,"groupId":391881,"name":"multi_atr2","groupName":"group_multi"},{"groupId":391882,"name":43,"groupName":"group_numeric"},{"groupId":391883,"name":"tag instance","groupName":"group_text"}],"createdAt":"2022-08-22T06:55:16.784Z","createdBy":{"email":"arturn@superannotate.com","role":"Admin"},"creationType":"Manual","updatedAt":"2022-08-22T06:55:48.591Z","updatedBy":{"email":"arturn@superannotate.com","role":"Admin"},"className":"tag_class"}],"comments":[],"tags":[]}

tests/integration/aggregations/test_df_processing.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22
from pathlib import Path
33

4-
import pytest
54
from src.superannotate import SAClient
5+
from src.superannotate import AppException
66
from tests.integration.base import BaseTestCase
77

88
sa = SAClient()
@@ -28,6 +28,10 @@ def test_filter_instances(self):
2828
{"example_image_1.jpg", "example_image_2.jpg"},
2929
)
3030

31+
def test_invalid_project_type(self):
32+
with self.assertRaisesRegexp(AppException, "The function is not supported for PointCloud projects."):
33+
sa.aggregate_annotations_as_df(self.folder_path, "PointCloud")
34+
3135

3236
class TestDFWithTagInstance(BaseTestCase):
3337
PROJECT_TYPE = "Vector"
@@ -40,3 +44,4 @@ def folder_path(self):
4044
def test_filter_instances(self):
4145
df = sa.aggregate_annotations_as_df(self.folder_path, self.PROJECT_TYPE)
4246
self.assertEqual(df.iloc[0]["type"], "tag")
47+

tests/integration/annotations/test_upload_annotations_from_folder_to_project.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,34 @@ def test_upload_big_annotations(self):
120120
assert [len(annotation["instances"]) > 1 for annotation in annotations].count(
121121
True
122122
) == 4
123+
124+
125+
126+
class TestExporeExportUploadVector(BaseTestCase):
127+
PROJECT_NAME = "Test-TestExporeExportUploadVector"
128+
PROJECT_DESCRIPTION = "Desc"
129+
PROJECT_TYPE = "Vector"
130+
TEST_FOLDER_PATH = "data_set/sample_explore_export"
131+
132+
@property
133+
def data_set(self):
134+
return Path(__file__).parent.parent.parent
135+
136+
@property
137+
def folder_path(self):
138+
return os.path.join(Path(__file__).parent.parent.parent, self.TEST_FOLDER_PATH)
139+
140+
def test_annotation_folder_upload_download(self):
141+
sa.attach_items(
142+
self.PROJECT_NAME,
143+
[
144+
{"name": "file_example.jpg", "url": "url_"}
145+
],
146+
)
147+
sa.create_annotation_classes_from_classes_json(
148+
self.PROJECT_NAME, f"{self.folder_path}/classes/classes.json"
149+
)
150+
uploaded, _, _ = sa.upload_annotations_from_folder_to_project(
151+
self.PROJECT_NAME, self.folder_path
152+
)
153+
assert len(uploaded) == 1

tests/integration/items/test_attach_items.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
from pathlib import Path
3+
from unittest import TestCase
34

5+
from src.superannotate import AppException
46
from src.superannotate import SAClient
57
from tests.integration.base import BaseTestCase
68

@@ -71,3 +73,17 @@ def test_limitation(self):
7173
self.assertRaises(
7274
Exception, sa.attach_items, self.PROJECT_NAME, self.scv_path_50k
7375
)
76+
77+
78+
class TestAttachItemsVectorArguments(TestCase):
79+
PROJECT_NAME = "TestAttachItemsVectorArguments"
80+
81+
def test_attach_items_invalid_payload(self):
82+
error_msg = [
83+
"attachments", "str type expected",
84+
"value is not a valid path",
85+
r"attachments\[0].url", "field required"
86+
]
87+
pattern = r"(\s+)" + r"(\s+)".join(error_msg)
88+
with self.assertRaisesRegexp(AppException, pattern):
89+
sa.attach_items(self.PROJECT_NAME, [{'name': "name"}])

0 commit comments

Comments
 (0)