From 8845bb1f098eb66b581c427fff75ea7c03bfac91 Mon Sep 17 00:00:00 2001 From: nareksa Date: Tue, 16 Apr 2024 16:45:29 +0400 Subject: [PATCH 1/5] fix get_annotations, item_ids with duplicate names --- .../lib/core/usecases/annotations.py | 9 +++---- .../annotations/test_get_annotations.py | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/superannotate/lib/core/usecases/annotations.py b/src/superannotate/lib/core/usecases/annotations.py index acfa651f2..25cbd3b56 100644 --- a/src/superannotate/lib/core/usecases/annotations.py +++ b/src/superannotate/lib/core/usecases/annotations.py @@ -1464,7 +1464,7 @@ def __init__( self._folder = folder self._service_provider = service_provider self._items = items - self._item_name_id_map = {} + self._item_id_name_map = {} self._item_names_provided = True self._big_annotations_queue = None @@ -1499,9 +1499,8 @@ def _prettify_annotations(self, annotations: List[dict]): if names_provided: re_struct[annotation["metadata"]["name"]] = annotation else: - re_struct[ - self._item_name_id_map[annotation["metadata"]["name"]] - ] = annotation + if annotation["metadata"]["id"] in self._item_id_name_map.keys(): + re_struct[annotation["metadata"]["id"]] = annotation try: return [re_struct[x] for x in self._items if x in re_struct] except KeyError: @@ -1589,7 +1588,7 @@ def execute(self): if not response.ok: raise AppException(response.error) items: List[BaseItemEntity] = response.data - self._item_name_id_map = {i.name: i.id for i in items} + self._item_id_name_map = {i.id: i.name for i in items} len_items, len_provided_items = len(items), len(self._items) if len_items != len_provided_items: self.reporter.log_warning( diff --git a/tests/integration/annotations/test_get_annotations.py b/tests/integration/annotations/test_get_annotations.py index 745a528f4..3a2de83e4 100644 --- a/tests/integration/annotations/test_get_annotations.py +++ b/tests/integration/annotations/test_get_annotations.py @@ -13,6 +13,7 @@ class TestGetAnnotations(BaseTestCase): PROJECT_NAME = "Test-get_annotations" FOLDER_NAME = "Test-get_annotations" + FOLDER_NAME_2 = "Test-get_annotations_2" PROJECT_DESCRIPTION = "Desc" PROJECT_TYPE = "Vector" TEST_FOLDER_PATH = "data_set/sample_project_vector" @@ -57,6 +58,30 @@ def test_get_annotations_by_ids(self): self.assertEqual(len(annotations), 4) + def test_get_annotations_by_ids_with_duplicate_names(self): + sa.create_folder(self.PROJECT_NAME, self.FOLDER_NAME_2) + self._attach_items(count=4, folder=self.FOLDER_NAME_2) # noqa + self._attach_items(count=4) # noqa + + sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, f"{self.folder_path}/classes/classes.json" + ) + _, _, _ = sa.upload_annotations_from_folder_to_project( + self.PROJECT_NAME, self.folder_path + ) + _, _, _ = sa.upload_annotations_from_folder_to_project( + f"{self.PROJECT_NAME}/{self.FOLDER_NAME_2}", self.folder_path + ) + items = sa.search_items(self.PROJECT_NAME) + folder_items = sa.search_items(f"{self.PROJECT_NAME}/{self.FOLDER_NAME_2}") + all_items = items + folder_items + + annotations = sa.get_annotations( + self._project["id"], [i["id"] for i in all_items] + ) + + self.assertEqual(len(annotations), 8) + def test_get_annotations_by_wrong_item_ids(self): annotations = sa.get_annotations(self._project["id"], [1, 2, 3]) From 52599742089070404e6cdc25e901221a97ee25e0 Mon Sep 17 00:00:00 2001 From: nareksa Date: Mon, 20 May 2024 11:17:14 +0400 Subject: [PATCH 2/5] changes in reqs and __build_query_string --- requirements.txt | 1 - src/superannotate/__init__.py | 2 +- src/superannotate/lib/core/usecases/items.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7ff9c88c2..ceba1348b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ boto3~=1.26 opencv-python-headless~=4.7 packaging~=23.1 plotly~=5.14 -email-validator~=2.0 pandas~=2.0 ffmpeg-python~=0.2 pillow>=9.5,~=10.0 diff --git a/src/superannotate/__init__.py b/src/superannotate/__init__.py index 7bd3916ad..b76ca5e1d 100644 --- a/src/superannotate/__init__.py +++ b/src/superannotate/__init__.py @@ -3,7 +3,7 @@ import sys -__version__ = "4.4.20" +__version__ = "4.4.21dev1" sys.path.append(os.path.split(os.path.realpath(__file__))[0]) diff --git a/src/superannotate/lib/core/usecases/items.py b/src/superannotate/lib/core/usecases/items.py index c1f51d0e8..2c4c67397 100644 --- a/src/superannotate/lib/core/usecases/items.py +++ b/src/superannotate/lib/core/usecases/items.py @@ -972,7 +972,7 @@ def __build_query_string(self, path, item_names): _, folder = extract_project_folder(path) if not folder: folder = "root" - query_str = f"metadata(name IN {str(item_names)}) AND folder={folder}" + query_str = f"metadata(name IN {str(item_names)}) AND folderName={folder}" return query_str From 1e52e9ccb5a66fb92c20c1b4f4d8eb84276fbef2 Mon Sep 17 00:00:00 2001 From: Vaghinak Basentsyan <84702976+VaghinakDev@users.noreply.github.com> Date: Wed, 22 May 2024 11:15:53 +0400 Subject: [PATCH 3/5] Update __init__.py --- src/superannotate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/superannotate/__init__.py b/src/superannotate/__init__.py index b76ca5e1d..c0da05b99 100644 --- a/src/superannotate/__init__.py +++ b/src/superannotate/__init__.py @@ -3,7 +3,7 @@ import sys -__version__ = "4.4.21dev1" +__version__ = "4.4.21b2" sys.path.append(os.path.split(os.path.realpath(__file__))[0]) From 94da4323c6750b0dd4558ca69b309cc156ce8dba Mon Sep 17 00:00:00 2001 From: Vaghinak Basentsyan <84702976+VaghinakDev@users.noreply.github.com> Date: Thu, 23 May 2024 10:35:59 +0400 Subject: [PATCH 4/5] Update __init__.py --- src/superannotate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/superannotate/__init__.py b/src/superannotate/__init__.py index c0da05b99..01e23dbb0 100644 --- a/src/superannotate/__init__.py +++ b/src/superannotate/__init__.py @@ -3,7 +3,7 @@ import sys -__version__ = "4.4.21b2" +__version__ = "4.4.21" sys.path.append(os.path.split(os.path.realpath(__file__))[0]) From 4023f22e6e1c5dffc739342290f003a5a67be730 Mon Sep 17 00:00:00 2001 From: Vaghinak Basentsyan <84702976+VaghinakDev@users.noreply.github.com> Date: Thu, 23 May 2024 10:39:41 +0400 Subject: [PATCH 5/5] Update CHANGELOG.rst --- CHANGELOG.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ce3efc9fc..2b4024fb8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,16 @@ History All release highlights of this project will be documented in this file. +4.4.21 - May 23, 2024 +_______________________ + + +**Updated** + + - Dependencies, removed ``email-validator``. + - ``add_items_to_subset`` added GenAI projects support. + + 4.4.20 - April 11, 2024 _______________________