Skip to content

Commit 47a9fc1

Browse files
committed
test fix
1 parent 9eba022 commit 47a9fc1

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

src/superannotate/lib/core/serviceproviders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ async def download_big_annotation(
346346
project: entities.ProjectEntity,
347347
download_path: str,
348348
postfix: str,
349-
item: dict,
349+
item: entities.BaseItemEntity,
350350
callback: Callable = None,
351351
):
352352
raise NotImplementedError

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,10 @@ def validate_item_names(self):
14081408
f"Dropping duplicates. Found {len_unique_items}/{len_items} unique items."
14091409
)
14101410
# Keep order required
1411-
self._item_names = [i for i in self._item_names if i in unique_item_names]
1411+
seen = set()
1412+
self._item_names = [
1413+
i for i in self._item_names if not (i in seen or seen.add(i))
1414+
]
14121415
elif self._item_names is None:
14131416
self._item_names_provided = False
14141417
condition = Condition("project_id", self._project.id, EQ) & Condition(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ def __init__(
772772

773773
def execute(self):
774774
if self.is_valid():
775-
team_users = {user.email for user in self._team.users}
775+
team_users = {user["email"] for user in self._team.users}
776776
# collecting pending team users
777777
team_users.update(
778778
{user["email"] for user in self._team.pending_invitations}

src/superannotate/lib/infrastructure/services/annotation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ async def download_big_annotation(
187187
project: entities.ProjectEntity,
188188
download_path: str,
189189
postfix: str,
190-
item: dict,
190+
item: entities.BaseItemEntity,
191191
callback: Callable = None,
192192
):
193-
item_id = item["id"]
194-
item_name = item["name"]
193+
item_id = item.id
194+
item_name = item.name
195195
query_params = {
196196
"team_id": project.team_id,
197197
"project_id": project.id,

tests/integration/annotations/test_download_annotations.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,14 @@ def test_download_annotations_from_folders_mul(self):
120120
[i for i in glob.iglob(annotations_path + "**/**", recursive=True)]
121121
)
122122
assert count == 31 + 5 # folder names and classes
123+
124+
def test_download_annotations_duplicated_names(self):
125+
self._attach_items(count=4)
126+
with tempfile.TemporaryDirectory() as temp_dir:
127+
with self.assertLogs("sa", level="INFO") as cm:
128+
sa.download_annotations(
129+
self.PROJECT_NAME, temp_dir, [self.IMAGE_NAME] * 4
130+
) # noqa
131+
assert (
132+
"INFO:sa:Dropping duplicates. Found 1/4 unique items." in cm.output
133+
)

tests/integration/annotations/test_get_annotations.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ def test_get_annotation(self): # to_delete
139139
a = sa.get_annotations(self.PROJECT_NAME)
140140
assert len(a) == count
141141

142+
def test_get_annotations_duplicated_names(self):
143+
self._attach_items(count=4)
144+
with self.assertLogs("sa", level="INFO") as cm:
145+
sa.get_annotations(self.PROJECT_NAME, [self.IMAGE_NAME] * 4)
146+
assert "INFO:sa:Dropping duplicates. Found 1/4 unique items." in cm.output
147+
142148

143149
class TestGetAnnotationsVideo(BaseTestCase):
144150
PROJECT_NAME = "test attach multiple video urls"

0 commit comments

Comments
 (0)