Skip to content

Commit a984031

Browse files
dshabinVaghinak Basentsyan
authored andcommitted
Fix df_
1 parent 5b55049 commit a984031

File tree

50 files changed

+208
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+208
-156
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3409,7 +3409,7 @@ def aggregate_annotations_as_df(
34093409
"""
34103410
from superannotate.lib.app.analytics.common import aggregate_annotations_as_df
34113411

3412-
aggregate_annotations_as_df(
3412+
return aggregate_annotations_as_df(
34133413
project_root,
34143414
include_classes_wo_annotations,
34153415
include_comments,

src/superannotate/lib/core/usecases.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import zipfile
1111
from abc import ABC
1212
from abc import abstractmethod
13-
from collections import Counter
1413
from collections import defaultdict
1514
from collections import namedtuple
1615
from functools import cached_property
@@ -3178,12 +3177,6 @@ def execute(self):
31783177
),
31793178
)
31803179
)
3181-
image_names = [
3182-
annotation_path.replace(constances.PIXEL_ANNOTATION_POSTFIX, "").replace(
3183-
constances.VECTOR_ANNOTATION_POSTFIX, ""
3184-
)
3185-
for annotation_path in annotation_paths
3186-
]
31873180
images_data = self._backend_service.get_bulk_images(
31883181
images=[image.name for image in images_detail],
31893182
folder_id=self._folder.uuid,
@@ -3201,7 +3194,7 @@ def execute(self):
32013194
annotations_to_upload = list(
32023195
filter(lambda detail: detail.id is not None, images_detail)
32033196
)
3204-
if len(images_data) < (len(image_names)):
3197+
if missing_annotations:
32053198
self._response.errors = AppException(
32063199
f"Couldn't find image {','.join(map(lambda x: x.path, missing_annotations))} for annotation upload."
32073200
)
@@ -4052,11 +4045,13 @@ def __init__(
40524045
def extensions(self):
40534046
if not self._extensions:
40544047
return constances.DEFAULT_IMAGE_EXTENSIONS
4048+
return self._extensions
40554049

40564050
@property
40574051
def exclude_file_patterns(self):
40584052
if not self._exclude_file_patterns:
40594053
return constances.DEFAULT_FILE_EXCLUDE_PATTERNS
4054+
return self._exclude_file_patterns
40604055

40614056
def validate_project_type(self):
40624057
if self._project.project_type == constances.ProjectType.VIDEO.value:
@@ -4181,7 +4176,9 @@ def execute(self):
41814176
images_to_upload = images_to_upload[: self.auth_data["availableImageCount"]]
41824177
uploaded_images = []
41834178
failed_images = []
4184-
with concurrent.futures.ThreadPoolExecutor(max_workers=self.MAX_WORKERS) as executor:
4179+
with concurrent.futures.ThreadPoolExecutor(
4180+
max_workers=self.MAX_WORKERS
4181+
) as executor:
41854182
results = [
41864183
executor.submit(self._upload_image, image_path)
41874184
for image_path in images_to_upload
@@ -4195,7 +4192,6 @@ def execute(self):
41954192
yield
41964193

41974194
uploaded = []
4198-
# duplicates = []
41994195
for i in range(0, len(uploaded_images), 500):
42004196
response = AttachFileUrlsUseCase(
42014197
project=self._project,

tests/convertors/test_consensus.py

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ def export_path(self):
2626
return os.path.join(dirname(dirname(__file__)), self.TEST_EXPORT_ROOT)
2727

2828
def test_consensus(self):
29-
annot_types = ['polygon', 'bbox', 'point']
30-
folder_names = ['consensus_1', 'consensus_2', 'consensus_3']
29+
annot_types = ["polygon", "bbox", "point"]
30+
folder_names = ["consensus_1", "consensus_2", "consensus_3"]
3131
df_column_names = [
32-
'creatorEmail', 'imageName', 'instanceId', 'area', 'className',
33-
'attributes', 'folderName', 'score'
32+
"creatorEmail",
33+
"imageName",
34+
"instanceId",
35+
"area",
36+
"className",
37+
"attributes",
38+
"folderName",
39+
"score",
3440
]
3541
export_path = self.export_path
3642
for i in range(1, 4):
@@ -39,47 +45,53 @@ def test_consensus(self):
3945
self.PROJECT_NAME, self.export_path + "/classes/classes.json"
4046
)
4147
sa.upload_images_from_folder_to_project(
42-
self.PROJECT_NAME, self.export_path + "/images", annotation_status="Completed"
48+
self.PROJECT_NAME,
49+
self.export_path + "/images",
50+
annotation_status="Completed",
4351
)
4452
for i in range(1, 4):
4553
sa.upload_images_from_folder_to_project(
46-
self.PROJECT_NAME + f'/{self.CONSENSUS_PREFIX}' + str(i),
54+
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
4755
self.export_path + "/images",
48-
annotation_status="Completed"
56+
annotation_status="Completed",
4957
)
5058
time.sleep(2)
51-
sa.upload_annotations_from_folder_to_project(self.PROJECT_NAME, self.export_path)
59+
sa.upload_annotations_from_folder_to_project(
60+
self.PROJECT_NAME, self.export_path
61+
)
5262
for i in range(1, 4):
5363
sa.upload_annotations_from_folder_to_project(
54-
self.PROJECT_NAME + f'/{self.CONSENSUS_PREFIX}' + str(i),
55-
self.export_path + f'/{self.CONSENSUS_PREFIX}' + str(i)
64+
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
65+
self.export_path + f"/{self.CONSENSUS_PREFIX}" + str(i),
5666
)
5767

5868
for annot_type in annot_types:
59-
res_df = sa.consensus(self.PROJECT_NAME, folder_names, annot_type=annot_type)
60-
#test content of projectName column
61-
assert sorted(res_df['folderName'].unique()) == folder_names
69+
res_df = sa.consensus(
70+
self.PROJECT_NAME, folder_names, annot_type=annot_type
71+
)
72+
# test content of projectName column
73+
assert sorted(res_df["folderName"].unique()) == folder_names
6274

63-
#test structure of resulting DataFrame
75+
# test structure of resulting DataFrame
6476
assert sorted(res_df.columns) == sorted(df_column_names)
6577

66-
#test lower bound of the score
67-
assert (res_df['score'] >= 0).all()
78+
# test lower bound of the score
79+
assert (res_df["score"] >= 0).all()
6880

69-
#test upper bound of the score
70-
assert (res_df['score'] <= 1).all()
81+
# test upper bound of the score
82+
assert (res_df["score"] <= 1).all()
7183

7284
image_names = [
73-
'bonn_000000_000019_leftImg8bit.png',
74-
'bielefeld_000000_000321_leftImg8bit.png'
85+
"bonn_000000_000019_leftImg8bit.png",
86+
"bielefeld_000000_000321_leftImg8bit.png",
7587
]
7688

77-
#test filtering images with given image names list
89+
# test filtering images with given image names list
7890
res_images = sa.consensus(
7991
self.PROJECT_NAME,
8092
folder_names,
8193
export_root=export_path,
82-
image_list=image_names
94+
image_list=image_names,
8395
)
8496

85-
assert sorted(res_images['imageName'].unique()) == sorted(image_names)
97+
assert sorted(res_images["imageName"].unique()) == sorted(image_names)

tests/convertors/test_dataloop.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pathlib import Path
2-
import pytest
32

3+
import pytest
44
import superannotate as sa
55

66

@@ -20,6 +20,7 @@ def test_dataloop_convert_vector(tmpdir):
2020
ptype = "Vector"
2121
# upload_project(out_dir, project_name, description, ptype)
2222

23+
2324
@pytest.mark.skip(reason="Need to adjust")
2425
def test_dataloop_convert_object(tmpdir):
2526
project_name = "dataloop2sa_vector_object"

tests/convertors/test_googlecloud.py

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

3+
import pytest
34
import superannotate as sa
45

5-
import pytest
66

77
@pytest.mark.skip(reason="Need to adjust")
88
def test_googlecloud_convert_web(tmpdir):

tests/convertors/test_labelbox.py

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

3+
import pytest
34
import superannotate as sa
45

5-
import pytest
66

77
@pytest.mark.skip(reason="Need to adjust")
88
def test_labelbox_convert_vector(tmpdir):

tests/convertors/test_sagemaker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from pathlib import Path
22

3-
import superannotate as sa
4-
53
import pytest
4+
import superannotate as sa
65

76

87
@pytest.mark.skip(reason="Need to adjust")

tests/convertors/test_supervisely.py

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

3-
import superannotate as sa
4-
53
import pytest
4+
import superannotate as sa
65

76

87
@pytest.mark.skip(reason="Need to adjust")
@@ -90,8 +89,11 @@ def test_supervisely_convert_keypoint(tmpdir):
9089
description = "supervisely keypoint"
9190
ptype = "Vector"
9291
# upload_project(out_dir, project_name, description, ptype)
92+
93+
9394
#
9495

96+
9597
@pytest.mark.skip(reason="Need to adjust")
9698
def test_supervisely_convert_instance_pixel(tmpdir):
9799
project_name = "supervisely_test_instance_pixel"

tests/convertors/test_vgg.py

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

3+
import pytest
34
import superannotate as sa
45

5-
import pytest
66

77
@pytest.mark.skip(reason="Need to adjust")
88
def test_vgg_convert_object(tmpdir):

tests/convertors/test_voc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from pathlib import Path
22

3-
import superannotate as sa
4-
53
import pytest
4+
import superannotate as sa
65

76

87
@pytest.mark.skip(reason="Need to adjust")

0 commit comments

Comments
 (0)