Skip to content

Commit 67bf31c

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
FRIDAY 8 fix
1 parent a1c5439 commit 67bf31c

File tree

6 files changed

+48
-21
lines changed

6 files changed

+48
-21
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
minversion = 3.0
33
log_cli=true
44
python_files = test_*.py
5-
;addopts = -n32 --dist=loadscope
5+
addopts = -n32 --dist=loadscope

src/superannotate/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import os
21
import logging.config
2+
import os
33

4-
from superannotate.version import __version__
54
from superannotate.lib.app.analytics.class_analytics import attribute_distribution
65
from superannotate.lib.app.analytics.class_analytics import class_distribution
76
from superannotate.lib.app.annotation_helpers import add_annotation_bbox_to_json
@@ -155,6 +154,7 @@
155154
from superannotate.lib.app.interface.sdk_interface import (
156155
upload_videos_from_folder_to_project,
157156
)
157+
from superannotate.version import __version__
158158

159159

160160
__all__ = [

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,9 @@ def get_project_settings(project: Union[str, dict]):
886886
"""
887887
project_name, folder_name = extract_project_folder(project)
888888
settings = controller.get_project_settings(project_name=project_name)
889-
settings = [BaseSerializers(attribute).serialize() for attribute in settings.data]
889+
settings = [
890+
SettingsSerializer(attribute).serialize() for attribute in settings.data
891+
]
890892
return settings
891893

892894

@@ -1143,9 +1145,6 @@ def assign_images(project: Union[str, dict], image_names: List[str], user: str):
11431145
logger.warning(
11441146
f"Skipping {user}. {user} is not a verified contributor for the {project_name}"
11451147
)
1146-
1147-
1148-
11491148
return
11501149

11511150
controller.assign_images(project_name, folder_name, image_names, user)

src/superannotate/lib/core/usecases.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ def execute(self):
129129
if not projects:
130130
self._response.errors = AppException("Project not found.")
131131
else:
132-
project = next((project for project in projects if project.name == self._name), None)
132+
project = next(
133+
(project for project in projects if project.name == self._name),
134+
None,
135+
)
133136
if not project:
134137
self._response.errors = AppException("Project not found")
135138
self._response.data = project
@@ -3156,6 +3159,7 @@ def execute(self):
31563159

31573160
class UploadAnnotationsUseCase(BaseUseCase):
31583161
MAX_WORKERS = 10
3162+
31593163
def __init__(
31603164
self,
31613165
project: ProjectEntity,
@@ -3335,9 +3339,18 @@ def execute(self):
33353339
else:
33363340
from_s3 = None
33373341

3338-
with concurrent.futures.ThreadPoolExecutor(max_workers=self.MAX_WORKERS) as executor:
3342+
with concurrent.futures.ThreadPoolExecutor(
3343+
max_workers=self.MAX_WORKERS
3344+
) as executor:
33393345
for image_id, image_info in auth_data["images"].items():
3340-
executor.submit(self.upload_to_s3, image_id, image_info, bucket, from_s3, image_id_name_map)
3346+
executor.submit(
3347+
self.upload_to_s3,
3348+
image_id,
3349+
image_info,
3350+
bucket,
3351+
from_s3,
3352+
image_id_name_map,
3353+
)
33413354

33423355
uploaded_annotations = [annotation.path for annotation in annotations_to_upload]
33433356
missing_annotations = [annotation.path for annotation in missing_annotations]
@@ -3353,7 +3366,9 @@ def execute(self):
33533366
)
33543367
return self._response
33553368

3356-
def upload_to_s3(self, image_id: int, image_info, bucket, from_s3, image_id_name_map):
3369+
def upload_to_s3(
3370+
self, image_id: int, image_info, bucket, from_s3, image_id_name_map
3371+
):
33573372
if from_s3:
33583373
file = io.BytesIO()
33593374
s3_object = from_s3.Object(
@@ -3367,13 +3382,11 @@ def upload_to_s3(self, image_id: int, image_info, bucket, from_s3, image_id_name
33673382

33683383
self.fill_classes_data(annotation_json)
33693384
bucket.put_object(
3370-
Key=image_info["annotation_json_path"],
3371-
Body=json.dumps(annotation_json),
3385+
Key=image_info["annotation_json_path"], Body=json.dumps(annotation_json),
33723386
)
33733387
if self._project.project_type == constances.ProjectType.PIXEL.value:
33743388
mask_filename = (
3375-
image_id_name_map[image_id].name
3376-
+ constances.ANNOTATION_MASK_POSTFIX
3389+
image_id_name_map[image_id].name + constances.ANNOTATION_MASK_POSTFIX
33773390
)
33783391
if from_s3:
33793392
file = io.BytesIO()
@@ -3383,9 +3396,7 @@ def upload_to_s3(self, image_id: int, image_info, bucket, from_s3, image_id_name
33833396
s3_object.download_file(file)
33843397
file.seek(0)
33853398
else:
3386-
with open(
3387-
f"{self._folder_path}/{mask_filename}", "rb"
3388-
) as mask_file:
3399+
with open(f"{self._folder_path}/{mask_filename}", "rb") as mask_file:
33893400
file = io.BytesIO(mask_file.read())
33903401

33913402
bucket.put_object(Key=image_info["annotation_bluemap_path"], Body=file)
@@ -4347,7 +4358,9 @@ def execute(self):
43474358
folder=self._folder,
43484359
limit=self.auth_data["availableImageCount"],
43494360
backend_service_provider=self._backend_client,
4350-
attachments=[image.entity for image in uploaded_images[i : i + 100]],
4361+
attachments=[
4362+
image.entity for image in uploaded_images[i : i + 100]
4363+
],
43514364
annotation_status=self._annotation_status,
43524365
).execute()
43534366

src/superannotate/lib/infrastructure/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import requests.packages.urllib3
1111
from lib.core.exceptions import AppException
1212
from lib.core.serviceproviders import SuerannotateServiceProvider
13-
from requests.exceptions import HTTPError
1413
from lib.infrastructure.helpers import timed_lru_cache
14+
from requests.exceptions import HTTPError
1515

1616
requests.packages.urllib3.disable_warnings()
1717

tests/integration/test_interface.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def test_delete_images(self):
4444
self.assertEqual(num_images, 0)
4545

4646
def test_delete_folder(self):
47-
print(sa.search_folders(self.PROJECT_NAME))
4847
with self.assertRaises(AppException):
4948
sa.delete_folders(self.PROJECT_NAME, ["non-existing folder"])
5049

@@ -75,3 +74,19 @@ def test_download_image_annotations(self):
7574
sa.upload_images_from_folder_to_project(self.PROJECT_NAME, self.folder_path)
7675
with tempfile.TemporaryDirectory() as temp_dir:
7776
sa.download_image_annotations(self.PROJECT_NAME, self.EXAMPLE_IMAGE_1, temp_dir)
77+
78+
def test_search_folder(self):
79+
team_users = sa.search_team_contributors()
80+
sa.share_project(self.PROJECT_NAME, team_users[0], "QA")
81+
sa.create_folder(self.PROJECT_NAME, self.TEST_FOLDER_NAME)
82+
data = sa.search_folders(self.PROJECT_NAME, return_metadata=True)
83+
folder_data = sa.search_folders(self.PROJECT_NAME, self.TEST_FOLDER_NAME, return_metadata=True)
84+
self.assertEqual(data, folder_data)
85+
86+
def test_get_project_settings(self):
87+
sa.set_project_settings(self.PROJECT_NAME, [{'attribute': 'ImageQuality', 'value': 'original'}])
88+
data = sa.get_project_settings(self.PROJECT_NAME)
89+
for elem in data:
90+
if elem["attribute"] == "ImageQuality":
91+
self.assertEqual(elem["value"], "original")
92+
break

0 commit comments

Comments
 (0)