Skip to content

Commit 8202cd9

Browse files
committed
Fix annotation log
1 parent 7325b0a commit 8202cd9

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,12 @@ def add_annotation_point_to_image(
25052505
"""
25062506
annotations = get_image_annotations(project, image_name)["annotation_json"]
25072507
annotations = add_annotation_point_to_json(
2508-
annotations, point, annotation_class_name, image_name,annotation_class_attributes, error
2508+
annotations,
2509+
point,
2510+
annotation_class_name,
2511+
image_name,
2512+
annotation_class_attributes,
2513+
error,
25092514
)
25102515
controller.upload_image_annotations(
25112516
*extract_project_folder(project), image_name, annotations

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
from lib.core.exceptions import ImageProcessingException
3636
from lib.core.plugin import ImagePlugin
3737
from lib.core.plugin import VideoPlugin
38+
from lib.core.reporter import Reporter
3839
from lib.core.repositories import BaseManageableRepository
3940
from lib.core.repositories import BaseReadOnlyRepository
4041
from lib.core.response import Response
4142
from lib.core.serviceproviders import SuerannotateServiceProvider
4243
from lib.core.usecases.base import BaseInteractiveUseCase
44+
from lib.core.usecases.base import BaseReportableUseCae
4345
from lib.core.usecases.base import BaseUseCase
4446
from lib.core.usecases.projects import GetAnnotationClassesUseCase
4547
from lib.core.validators import BaseAnnotationValidator
@@ -2463,16 +2465,17 @@ def execute(self):
24632465
return self._response
24642466

24652467

2466-
class GetImageAnnotationsUseCase(BaseUseCase):
2468+
class GetImageAnnotationsUseCase(BaseReportableUseCae):
24672469
def __init__(
24682470
self,
2471+
reporter: Reporter,
24692472
service: SuerannotateServiceProvider,
24702473
project: ProjectEntity,
24712474
folder: FolderEntity,
24722475
image_name: str,
24732476
images: BaseManageableRepository,
24742477
):
2475-
super().__init__()
2478+
super().__init__(reporter)
24762479
self._service = service
24772480
self._project = project
24782481
self._folder = folder
@@ -2524,7 +2527,7 @@ def execute(self):
25242527
headers=credentials["annotation_json_path"]["headers"],
25252528
)
25262529
if not response.ok:
2527-
logger.warning("Couldn't load annotations.")
2530+
self.reporter.log_warning("Couldn't load annotations.")
25282531
self._response.data = data
25292532
return self._response
25302533
data["annotation_json"] = response.json()

src/superannotate/lib/infrastructure/controller.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ def get_image_annotations(
991991
folder=folder,
992992
image_name=image_name,
993993
images=ImageRepository(service=self._backend_client),
994+
reporter=Reporter(log_info=False, log_warning=False),
994995
)
995996
return use_case.execute()
996997

tests/integration/annotations/test_annotation_adding.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,31 @@ def test_add_point_to_empty_image(self):
7676
'classId': -1
7777
})
7878

79+
def test_add_bbox_to_empty_annotation(self):
80+
sa.upload_images_from_folder_to_project(
81+
self.PROJECT_NAME, self.folder_path, annotation_status="InProgress"
82+
)
83+
84+
sa.add_annotation_bbox_to_image(
85+
self.PROJECT_NAME, self.EXAMPLE_IMAGE_1, [10, 10, 500, 100], "test_add"
86+
)
87+
88+
annotations_new = sa.get_image_annotations(
89+
self.PROJECT_NAME, self.EXAMPLE_IMAGE_1
90+
)["annotation_json"]
91+
92+
self.assertEqual(annotations_new['instances'][0], {
93+
'creationType': 'Preannotation',
94+
'className': 'test_add', 'visible': True,
95+
'locked': False, 'probability': 100,
96+
'attributes': [],
97+
'type': 'bbox',
98+
'pointLabels': {},
99+
'groupId': 0,
100+
'points': {'x1': 10.0, 'x2': 500.0, 'y1': 10.0, 'y2': 100.0},
101+
'classId': -1
102+
})
103+
79104

80105
def test_add_bbox(self):
81106
sa.upload_images_from_folder_to_project(

0 commit comments

Comments
 (0)