From ef3f8f449f80985bdce42a34dbe46abe66f40341 Mon Sep 17 00:00:00 2001 From: nareksa Date: Thu, 30 Nov 2023 20:03:53 +0400 Subject: [PATCH] fix upload_annotations set_defaults --- CHANGELOG.rst | 2 +- src/superannotate/lib/app/interface/sdk_interface.py | 1 + src/superannotate/lib/core/usecases/annotations.py | 5 +++++ src/superannotate/lib/infrastructure/controller.py | 2 ++ tests/integration/annotations/test_upload_annotations.py | 2 ++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 110c42315..8c9080e81 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ History All release highlights of this project will be documented in this file. 4.4.16 - November 12, 2023 -_______________________ +__________________________ **Added** diff --git a/src/superannotate/lib/app/interface/sdk_interface.py b/src/superannotate/lib/app/interface/sdk_interface.py index a467bbe8e..162940830 100644 --- a/src/superannotate/lib/app/interface/sdk_interface.py +++ b/src/superannotate/lib/app/interface/sdk_interface.py @@ -1668,6 +1668,7 @@ def upload_annotations( folder=folder, annotations=annotations, keep_status=keep_status, + user=self.controller.current_user, ) if response.errors: raise AppException(response.errors) diff --git a/src/superannotate/lib/core/usecases/annotations.py b/src/superannotate/lib/core/usecases/annotations.py index 6fa39da63..f3b5d963a 100644 --- a/src/superannotate/lib/core/usecases/annotations.py +++ b/src/superannotate/lib/core/usecases/annotations.py @@ -295,6 +295,7 @@ def __init__( folder: FolderEntity, annotations: List[dict], service_provider: BaseServiceProvider, + user: UserEntity, keep_status: bool = False, ): super().__init__(reporter) @@ -304,6 +305,7 @@ def __init__( self._service_provider = service_provider self._keep_status = keep_status self._report = Report([], [], [], []) + self._user = user def validate_project_type(self): if self._project.type == constants.ProjectType.PIXEL.value: @@ -439,6 +441,9 @@ def execute(self): annotation_name = annotation["metadata"]["name"] item = name_item_map.get(annotation_name) if item: + annotation = UploadAnnotationUseCase.set_defaults( + self._user.email, annotation, self._project.type + ) items_to_upload.append( ItemToUpload(item=item, annotation_json=annotation) ) diff --git a/src/superannotate/lib/infrastructure/controller.py b/src/superannotate/lib/infrastructure/controller.py index 82e139d36..98a9d343f 100644 --- a/src/superannotate/lib/infrastructure/controller.py +++ b/src/superannotate/lib/infrastructure/controller.py @@ -568,6 +568,7 @@ def upload_multiple( folder: FolderEntity, annotations: List[dict], keep_status: bool, + user: UserEntity, ): use_case = usecases.UploadAnnotationsUseCase( reporter=Reporter(), @@ -576,6 +577,7 @@ def upload_multiple( annotations=annotations, service_provider=self.service_provider, keep_status=keep_status, + user=user, ) return use_case.execute() diff --git a/tests/integration/annotations/test_upload_annotations.py b/tests/integration/annotations/test_upload_annotations.py index 302e35519..cb10e81c7 100644 --- a/tests/integration/annotations/test_upload_annotations.py +++ b/tests/integration/annotations/test_upload_annotations.py @@ -71,6 +71,8 @@ def test_annotation_folder_upload_download(self): assert i["annotation_status"] == "InProgress" assert annotation["instances"][-1]["type"] == "tag" assert annotation["instances"][-2]["type"] == "tag" + assert annotation["instances"][-2]["probability"] == 100 + assert annotation["instances"][-2]["creationType"] == "Preannotation" def test_upload_keep_true(self): self._attach_items()