Skip to content

Commit 3a4181a

Browse files
authored
Merge pull request #223 from superannotateai/sdk-193-2
Sdk 193 2
2 parents c8e4c1a + 4bdb9f9 commit 3a4181a

File tree

7 files changed

+710
-653
lines changed

7 files changed

+710
-653
lines changed

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import concurrent.futures
21
import io
32
import json
43
import logging
54
import os
65
import tempfile
76
import time
8-
from collections import namedtuple
97
from pathlib import Path
108
from typing import Iterable
119
from typing import List
@@ -1750,7 +1748,9 @@ def upload_videos_from_folder_to_project(
17501748
f"{len(duplicates)} already existing images found that won't be uploaded."
17511749
)
17521750
if not images_to_upload:
1753-
logger.warning(f"{len(duplicates)} already existing images found that won't be uploaded.")
1751+
logger.warning(
1752+
f"{len(duplicates)} already existing images found that won't be uploaded."
1753+
)
17541754
continue
17551755
if use_case.is_valid():
17561756
with tqdm(
@@ -2009,14 +2009,16 @@ def move_image(
20092009
:type copy_pin: bool
20102010
"""
20112011
source_project_name, source_folder_name = extract_project_folder(source_project)
2012-
destination_project_name, destination_folder = extract_project_folder(destination_project)
2012+
destination_project_name, destination_folder = extract_project_folder(
2013+
destination_project
2014+
)
20132015
response = controller.move_image(
20142016
from_project_name=source_project_name,
20152017
from_folder_name=source_folder_name,
20162018
to_project_name=destination_project_name,
20172019
to_folder_name=destination_folder,
20182020
image_name=image_name,
2019-
copy_annotation_status=copy_annotation_status
2021+
copy_annotation_status=copy_annotation_status,
20202022
)
20212023
if response.errors:
20222024
raise AppException(response.errors)
@@ -2269,11 +2271,13 @@ def attach_image_urls_to_project(
22692271
annotation_status=annotation_status,
22702272
)
22712273
if use_case.is_valid():
2272-
with tqdm(total=use_case.attachments_count, desc="Attaching urls") as progress_bar:
2274+
with tqdm(
2275+
total=use_case.attachments_count, desc="Attaching urls"
2276+
) as progress_bar:
22732277
for _ in use_case.execute():
22742278
progress_bar.update(1)
22752279
uploaded, duplications = use_case.data
2276-
uploaded = [i['name'] for i in uploaded]
2280+
uploaded = [i["name"] for i in uploaded]
22772281
duplications.extend(duplicate_images)
22782282
failed_images = [
22792283
image["name"]
@@ -2320,11 +2324,13 @@ def attach_video_urls_to_project(
23202324
annotation_status=annotation_status,
23212325
)
23222326
if use_case.is_valid():
2323-
with tqdm(total=use_case.attachments_count, desc="Attaching urls") as progress_bar:
2327+
with tqdm(
2328+
total=use_case.attachments_count, desc="Attaching urls"
2329+
) as progress_bar:
23242330
for _ in use_case.execute():
23252331
progress_bar.update(1)
23262332
uploaded, duplications = use_case.data
2327-
uploaded = [i['name'] for i in uploaded]
2333+
uploaded = [i["name"] for i in uploaded]
23282334
duplications.extend(duplicate_images)
23292335
failed_images = [
23302336
image["name"]
@@ -3318,7 +3324,7 @@ def upload_image_to_project(
33183324
image=img,
33193325
annotation_status=annotation_status,
33203326
from_s3_bucket=from_s3_bucket,
3321-
image_quality_in_editor=image_quality_in_editor
3327+
image_quality_in_editor=image_quality_in_editor,
33223328
)
33233329
if response.errors:
33243330
raise AppException(response.errors)
@@ -3529,11 +3535,13 @@ def attach_document_urls_to_project(
35293535
annotation_status=annotation_status,
35303536
)
35313537
if use_case.is_valid():
3532-
with tqdm(total=use_case.attachments_count, desc="Attaching urls") as progress_bar:
3538+
with tqdm(
3539+
total=use_case.attachments_count, desc="Attaching urls"
3540+
) as progress_bar:
35333541
for _ in use_case.execute():
35343542
progress_bar.update(1)
35353543
uploaded, duplications = use_case.data
3536-
uploaded = [i['name'] for i in uploaded]
3544+
uploaded = [i["name"] for i in uploaded]
35373545
duplications.extend(duplicate_images)
35383546
failed_images = [
35393547
image["name"]

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

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
class CreateFolderUseCase(BaseUseCase):
2020
def __init__(
21-
self,
22-
project: ProjectEntity,
23-
folder: FolderEntity,
24-
folders: BaseManageableRepository,
21+
self,
22+
project: ProjectEntity,
23+
folder: FolderEntity,
24+
folders: BaseManageableRepository,
2525
):
2626
super().__init__()
2727
self._project = project
@@ -32,12 +32,12 @@ def validate_folder(self):
3232
if not self._folder.name:
3333
raise AppValidationException("Folder name cannot be empty.")
3434
if (
35-
len(
36-
set(self._folder.name).intersection(
37-
constances.SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES
38-
)
35+
len(
36+
set(self._folder.name).intersection(
37+
constances.SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES
3938
)
40-
> 0
39+
)
40+
> 0
4141
):
4242
self._folder.name = "".join(
4343
"_"
@@ -56,14 +56,13 @@ def execute(self):
5656
return self._response
5757

5858

59-
6059
class GetFolderUseCase(BaseUseCase):
6160
def __init__(
62-
self,
63-
project: ProjectEntity,
64-
folders: BaseReadOnlyRepository,
65-
folder_name: str,
66-
team_id: int,
61+
self,
62+
project: ProjectEntity,
63+
folders: BaseReadOnlyRepository,
64+
folder_name: str,
65+
team_id: int,
6766
):
6867
super().__init__()
6968
self._project = project
@@ -73,9 +72,9 @@ def __init__(
7372

7473
def execute(self):
7574
condition = (
76-
Condition("name", self._folder_name, EQ)
77-
& Condition("team_id", self._team_id, EQ)
78-
& Condition("project_id", self._project.uuid, EQ)
75+
Condition("name", self._folder_name, EQ)
76+
& Condition("team_id", self._team_id, EQ)
77+
& Condition("project_id", self._project.uuid, EQ)
7978
)
8079
try:
8180
self._response.data = self._folders.get_one(condition)
@@ -86,12 +85,12 @@ def execute(self):
8685

8786
class SearchFoldersUseCase(BaseUseCase):
8887
def __init__(
89-
self,
90-
project: ProjectEntity,
91-
folders: BaseReadOnlyRepository,
92-
condition: Condition,
93-
folder_name: str = None,
94-
include_users=False,
88+
self,
89+
project: ProjectEntity,
90+
folders: BaseReadOnlyRepository,
91+
condition: Condition,
92+
folder_name: str = None,
93+
include_users=False,
9594
):
9695
super().__init__()
9796
self._project = project
@@ -102,10 +101,10 @@ def __init__(
102101

103102
def execute(self):
104103
condition = (
105-
self._condition
106-
& Condition("project_id", self._project.uuid, EQ)
107-
& Condition("team_id", self._project.team_id, EQ)
108-
& Condition("includeUsers", self._include_users, EQ)
104+
self._condition
105+
& Condition("project_id", self._project.uuid, EQ)
106+
& Condition("team_id", self._project.team_id, EQ)
107+
& Condition("includeUsers", self._include_users, EQ)
109108
)
110109
if self._folder_name:
111110
condition &= Condition("name", self._folder_name, EQ)
@@ -115,10 +114,10 @@ def execute(self):
115114

116115
class DeleteFolderUseCase(BaseUseCase):
117116
def __init__(
118-
self,
119-
project: ProjectEntity,
120-
folders: BaseManageableRepository,
121-
folders_to_delete: List[FolderEntity],
117+
self,
118+
project: ProjectEntity,
119+
folders: BaseManageableRepository,
120+
folders_to_delete: List[FolderEntity],
122121
):
123122
super().__init__()
124123
self._project = project
@@ -137,7 +136,7 @@ def execute(self):
137136

138137
class UpdateFolderUseCase(BaseUseCase):
139138
def __init__(
140-
self, folders: BaseManageableRepository, folder: FolderEntity,
139+
self, folders: BaseManageableRepository, folder: FolderEntity,
141140
):
142141
super().__init__()
143142
self._folders = folders
@@ -147,12 +146,12 @@ def validate_folder(self):
147146
if not self._folder.name:
148147
raise AppValidationException("Folder name cannot be empty.")
149148
if (
150-
len(
151-
set(self._folder.name).intersection(
152-
constances.SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES
153-
)
149+
len(
150+
set(self._folder.name).intersection(
151+
constances.SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES
154152
)
155-
> 0
153+
)
154+
> 0
156155
):
157156
self._folder.name = "".join(
158157
"_"
@@ -175,11 +174,11 @@ def execute(self):
175174

176175
class AssignFolderUseCase(BaseUseCase):
177176
def __init__(
178-
self,
179-
service: SuerannotateServiceProvider,
180-
project_entity: ProjectEntity,
181-
folder: FolderEntity,
182-
users: List[str],
177+
self,
178+
service: SuerannotateServiceProvider,
179+
project_entity: ProjectEntity,
180+
folder: FolderEntity,
181+
users: List[str],
183182
):
184183
super().__init__()
185184
self._service = service

0 commit comments

Comments
 (0)