Skip to content

Commit 8dafe58

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Added logger
1 parent ea19543 commit 8dafe58

22 files changed

+57
-45
lines changed

src/superannotate.egg-info/SOURCES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ src/superannotate/lib/app/interface/sdk_interface.py
131131
src/superannotate/lib/app/interface/sdk/__init__.py
132132
src/superannotate/lib/app/interface/sdk/folders.py
133133
src/superannotate/lib/app/interface/sdk/project.py
134+
src/superannotate/lib/app/mixp/__init__.py
135+
src/superannotate/lib/app/mixp/config.py
136+
src/superannotate/lib/app/mixp/decorators.py
137+
src/superannotate/lib/app/mixp/utils/__init__.py
138+
src/superannotate/lib/app/mixp/utils/parsers.py
134139
src/superannotate/lib/app/superannotate/__init__.py
135140
src/superannotate/lib/core/__init__.py
136141
src/superannotate/lib/core/conditions.py

src/superannotate.egg-info/requires.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ google-cloud-storage>=1.33.0
1818
azure-storage-blob>=12.6.0
1919
fire==0.4.0
2020
Shapely>=1.7.1
21+
mixpanel>=4.8.3

src/superannotate/lib/app/helpers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ def get_s3_annotation_paths(folder_path, s3_bucket, annotation_paths, recursive)
7272
paginator = s3_client.get_paginator("list_objects_v2")
7373
for data in paginator.paginate(Bucket=s3_bucket, Prefix=folder_path):
7474
for annotation in data["Contents"]:
75-
if (
76-
annotation["Key"].endswith(VECTOR_ANNOTATION_POSTFIX)
77-
or annotation["Key"].endswith(PIXEL_ANNOTATION_POSTFIX)
78-
):
75+
if annotation["Key"].endswith(VECTOR_ANNOTATION_POSTFIX) or annotation[
76+
"Key"
77+
].endswith(PIXEL_ANNOTATION_POSTFIX):
7978
annotation_paths.append(annotation["Key"])
8079
return list(set(annotation_paths))
8180

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from tqdm import tqdm
4242

4343
logger = logging.getLogger()
44+
logger.setLevel(logging.INFO)
4445

4546

4647
controller = Controller(logger)
@@ -196,7 +197,7 @@ def create_project_from_metadata(project_metadata):
196197
)
197198
if response.errors:
198199
raise Exception(response.errors)
199-
return response.data
200+
return ProjectSerializer(response.data).serialize()
200201

201202

202203
@Trackable
@@ -530,8 +531,7 @@ def copy_image(
530531
is_pinned=1,
531532
)
532533
logger.info(
533-
f"Copied image {source_project_name}/{source_folder_name}"
534-
f" to {destination_project}/{destination_folder}/{image_name}."
534+
f"Copied image {source_project}" f" to {destination_project}/{image_name}."
535535
)
536536

537537

@@ -760,7 +760,7 @@ def move_images(source_project, image_names, destination_project, *_, **__):
760760
+ message_postfix.format(from_path=source_project, to_path=destination_project)
761761
)
762762

763-
return len(image_names) - moved_count
763+
return list(set(image_names) - set(moved_images))
764764

765765

766766
@Trackable
@@ -956,7 +956,10 @@ def delete_image(project, image_name):
956956
:type image_name: str
957957
"""
958958
project_name, _ = extract_project_folder(project)
959-
controller.delete_image(image_name=image_name, project_name=project_name)
959+
response = controller.delete_image(image_name=image_name, project_name=project_name)
960+
if response.errors:
961+
raise AppException("Couldn't delete image ")
962+
logger.info(f"Successfully deleted image {image_name}.")
960963

961964

962965
@Trackable
@@ -1106,9 +1109,11 @@ def assign_folder(project_name, folder_name, users):
11061109
:param users: list of user emails
11071110
:type users: list of str
11081111
"""
1109-
controller.assign_folder(
1112+
response = controller.assign_folder(
11101113
project_name=project_name, folder_name=folder_name, users=users
11111114
)
1115+
if response.errors:
1116+
raise AppException(response.errors)
11121117

11131118

11141119
@Trackable
@@ -2138,7 +2143,7 @@ def create_fuse_image(
21382143
def download_image(
21392144
project,
21402145
image_name,
2141-
local_dir_path=".",
2146+
local_dir_path="./",
21422147
include_annotations=False,
21432148
include_fuse=False,
21442149
include_overlay=False,

src/superannotate/lib/core/usecases.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ def __init__(
13701370

13711371
def execute(self):
13721372
self._images.delete(self._image.uuid, self._team_id, self._project_id)
1373+
return self._response
13731374

13741375

13751376
class GetImageMetadataUseCase(BaseUseCase):
@@ -1433,7 +1434,7 @@ def __init__(
14331434
def execute(self):
14341435
moved_images = []
14351436
for i in range(0, len(self._image_names), self.CHUNK_SIZE):
1436-
moved_images.append(
1437+
moved_images.extend(
14371438
self._backend_service.move_images_between_folders(
14381439
team_id=self._project.team_id,
14391440
project_id=self._project.uuid,
@@ -1580,15 +1581,17 @@ def validate_project_type(self):
15801581
def execute(self):
15811582
if self.is_valid():
15821583
for i in range(0, len(self._image_names), self.CHUNK_SIZE):
1583-
self._response.data = self._service.assign_images(
1584+
is_assigned = self._service.assign_images(
15841585
team_id=self._project.team_id,
15851586
project_id=self._project.uuid,
15861587
folder_name=self._folder_name,
15871588
user=self._user,
15881589
image_names=self._image_names[
1589-
i : i + self.CHUNK_SIZE
1590-
], # noqa: E203
1590+
i : i + self.CHUNK_SIZE # noqa: E203
1591+
],
15911592
)
1593+
self._response.data = is_assigned
1594+
logger.info(f"Assign images to user {self._user}")
15921595

15931596
return self._response
15941597

@@ -1657,12 +1660,20 @@ def __init__(
16571660
self._users = users
16581661

16591662
def execute(self):
1660-
self._response.data = self._service.assign_folder(
1663+
is_assigned = self._service.assign_folder(
16611664
team_id=self._project_entity.team_id,
16621665
project_id=self._project_entity.uuid,
16631666
folder_name=self._folder_name,
16641667
users=self._users,
16651668
)
1669+
if is_assigned:
1670+
logger.info(
1671+
f'Assigned {self._folder_name} to users: {", ".join(self._users)}'
1672+
)
1673+
else:
1674+
self._response.errors = AppException(
1675+
"Couldn't assign folder to users: {', '.join(self._users)"
1676+
)
16661677
return self._response
16671678

16681679

@@ -1962,7 +1973,7 @@ def execute(self):
19621973
self._response.data = data
19631974
return self._response
19641975
data["annotation_json"] = response.json()
1965-
data["annotation_json_filename"] = f"{self._image_name}{file_postfix}.json"
1976+
data["annotation_json_filename"] = f"{self._image_name}{file_postfix}"
19661977
if self._project.project_type == constances.ProjectType.PIXEL.value:
19671978
annotation_blue_map_creds = credentials["annotation_bluemap_path"]
19681979
response = requests.get(
@@ -2055,7 +2066,7 @@ def execute(self):
20552066
if not response.ok:
20562067
raise AppException(f"Couldn't load annotations {response.text}")
20572068
data["preannotation_json"] = response.json()
2058-
data["preannotation_json_filename"] = f"{self._image_name}{file_postfix}.json"
2069+
data["preannotation_json_filename"] = f"{self._image_name}{file_postfix}"
20592070
if self._project.project_type == constances.ProjectType.PIXEL.value:
20602071
annotation_blue_map_creds = credentials["annotation_bluemap_path"]
20612072
response = requests.get(
@@ -4200,13 +4211,13 @@ def execute(self):
42004211
yield
42014212

42024213
uploaded = []
4203-
for i in range(0, len(uploaded_images), 500):
4214+
for i in range(0, len(uploaded_images), 100):
42044215
response = AttachFileUrlsUseCase(
42054216
project=self._project,
42064217
folder=self._folder,
42074218
limit=self.auth_data["availableImageCount"],
42084219
backend_service_provider=self._backend_client,
4209-
attachments=[image.entity for image in uploaded_images],
4220+
attachments=[image.entity for image in uploaded_images[i : i + 100]],
42104221
annotation_status=self._annotation_status,
42114222
).execute()
42124223

src/superannotate/lib/infrastructure/services.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import time
21
from contextlib import contextmanager
32
from datetime import datetime
43
from typing import Dict
@@ -74,7 +73,6 @@ def _request(
7473
url, **kwargs, headers=headers_dict, params=params, timeout=60
7574
)
7675
if response.status_code == 404 and retried < 3:
77-
time.sleep(1)
7876
return self._request(
7977
url,
8078
method="get",

tests/convertors/test_conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,4 @@ def test_upload_annotations_with_template_id(self):
258258
)
259259
sa.upload_annotations_from_folder_to_project(project, out_path)
260260
image_metadata = sa.get_image_annotations(project_name, "t.png")
261-
assert image_metadata["annotation_json"]["instances"][0]["templateId"] == -1
261+
self.assertEqual(image_metadata["annotation_json"]["instances"][0]["templateId"], -1)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"id":776351,"project_id":108297,"name":"person","color":"#96963a","count":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z","attribute_groups":[]},{"id":776352,"project_id":108297,"name":"car","color":"#b01cb4","count":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z","attribute_groups":[{"id":297564,"class_id":776352,"name":"color","is_multiselect":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z","attributes":[{"id":1077736,"group_id":297564,"project_id":108297,"name":"red","count":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z"},{"id":1077737,"group_id":297564,"project_id":108297,"name":"blue","count":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z"},{"id":1077738,"group_id":297564,"project_id":108297,"name":"green","count":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z"},{"id":1077739,"group_id":297564,"project_id":108297,"name":"yellow","count":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z"}]}]},{"id":776353,"project_id":108297,"name":"tree","color":"#249e9e","count":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z","attribute_groups":[]},{"id":776354,"project_id":108297,"name":"sign","color":"#fed339","count":0,"createdAt":"2021-08-27T07:13:53.000Z","updatedAt":"2021-08-27T07:13:53.000Z","attribute_groups":[]}]
1+
[{"id":776731,"project_id":108441,"name":"person","color":"#96963a","count":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z","attribute_groups":[]},{"id":776732,"project_id":108441,"name":"car","color":"#b01cb4","count":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z","attribute_groups":[{"id":297688,"class_id":776732,"name":"color","is_multiselect":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z","attributes":[{"id":1077990,"group_id":297688,"project_id":108441,"name":"red","count":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z"},{"id":1077991,"group_id":297688,"project_id":108441,"name":"blue","count":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z"},{"id":1077992,"group_id":297688,"project_id":108441,"name":"green","count":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z"},{"id":1077993,"group_id":297688,"project_id":108441,"name":"yellow","count":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z"}]}]},{"id":776733,"project_id":108441,"name":"tree","color":"#249e9e","count":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z","attribute_groups":[]},{"id":776734,"project_id":108441,"name":"sign","color":"#fed339","count":0,"createdAt":"2021-08-27T08:58:44.000Z","updatedAt":"2021-08-27T08:58:44.000Z","attribute_groups":[]}]

0 commit comments

Comments
 (0)