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 _______________________ 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..01e23dbb0 100644 --- a/src/superannotate/__init__.py +++ b/src/superannotate/__init__.py @@ -3,7 +3,7 @@ import sys -__version__ = "4.4.20" +__version__ = "4.4.21" sys.path.append(os.path.split(os.path.realpath(__file__))[0]) 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/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 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])