Skip to content

Commit 714ee85

Browse files
committed
Fix logs
1 parent e377520 commit 714ee85

File tree

12 files changed

+53
-19
lines changed

12 files changed

+53
-19
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
from lib.infrastructure.repositories import ConfigRepository
2424

2525

26-
controller = Controller.get_default()
26+
controller = Controller()
27+
controller.retrieve_configs(constances.CONFIG_FILE_LOCATION)
2728

2829

2930
class CLIFacade(BaseInterfaceFacade):

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,7 @@ def add_annotation_comment_to_image(
24162416
image_name: NotEmptyStr,
24172417
comment_text: NotEmptyStr,
24182418
comment_coords: List[float],
2419-
comment_author: NotEmptyStr,
2419+
comment_author: EmailStr,
24202420
resolved: Optional[StrictBool] = False,
24212421
):
24222422
"""Add a comment to SuperAnnotate format annotation JSON

src/superannotate/lib/app/mixp/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def __call__(self, *args, **kwargs):
8888
else:
8989
raise Exception(
9090
"SuperAnnotate config file not found."
91-
f" Please provide correct config file location to sa.init(<path>) or use "
92-
f"CLI's superannotate init to generate default location config file."
91+
" Please provide correct config file location to sa.init(<path>) or use "
92+
"CLI's superannotate init to generate default location config file."
9393
)
9494
except Exception as e:
9595
self._success = False

src/superannotate/lib/app/mixp/utils/parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,4 +1226,4 @@ def get_annotations_per_frame(*args, **kwargs):
12261226
return {
12271227
"event_name": "get_annotations_per_frame",
12281228
"properties": {"Project": project, "fps": fps},
1229-
}
1229+
}

src/superannotate/lib/core/data_handlers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
from typing import Dict
99
from typing import List
1010

11-
from superannotate_schemas.schemas.classes import AnnotationClass
12-
from superannotate_schemas.schemas.classes import Attribute
13-
from superannotate_schemas.schemas.classes import AttributeGroup
14-
1511
import lib.core as constances
1612
from lib.core.enums import ClassTypeEnum
1713
from lib.core.reporter import Reporter
14+
from superannotate_schemas.schemas.classes import AnnotationClass
15+
from superannotate_schemas.schemas.classes import Attribute
16+
from superannotate_schemas.schemas.classes import AttributeGroup
1817

1918

2019
class BaseDataHandler(metaclass=ABCMeta):

src/superannotate/lib/core/reporter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def finish_progress(self):
6363
self.progress_bar.close()
6464

6565
def update_progress(self, value: int = 1):
66-
self.progress_bar.update(value)
66+
if self.progress_bar:
67+
self.progress_bar.update(value)
6768

6869
def generate_report(self) -> str:
6970
report = ""

src/superannotate/lib/core/serviceproviders.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import List
66
from typing import Tuple
77

8+
from lib.core.reporter import Reporter
89
from lib.core.service_types import ServiceResponse
910

1011

@@ -304,5 +305,12 @@ def get_limitations(
304305
raise NotImplementedError
305306

306307
@abstractmethod
307-
def get_annotations(self, project_id: int, team_id: int, folder_id: int, items: List[str]) -> List[dict]:
308+
def get_annotations(
309+
self,
310+
project_id: int,
311+
team_id: int,
312+
folder_id: int,
313+
items: List[str],
314+
reporter: Reporter
315+
) -> List[dict]:
308316
raise NotImplementedError

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,24 @@ def validate_item_names(self):
514514
self._item_names = item_names
515515

516516
def execute(self):
517+
items_count = len(self._item_names)
518+
self.reporter.log_info(
519+
f"Getting {items_count} annotations from "
520+
f"{self._project.name}{f'/{self._folder.name}' if self._folder else ''}."
521+
)
522+
self.reporter.start_progress(items_count)
517523
annotations = self._client.get_annotations(
518524
team_id=self._project.team_id,
519525
project_id=self._project.uuid,
520526
folder_id=self._folder.uuid,
521-
items=self._item_names
527+
items=self._item_names,
528+
reporter=self.reporter
522529
)
530+
received_items_count = len(annotations)
531+
if items_count > received_items_count:
532+
self.reporter.log_warning(
533+
f"Could not find annotations for {items_count - received_items_count}/{items_count} items."
534+
)
523535
self._response.data = annotations
524536
return self._response
525537

@@ -549,14 +561,16 @@ def execute(self):
549561
item_names=[self._video_name],
550562
backend_service_provider=self._client
551563
).execute()
564+
generator = VideoFrameGenerator(response.data[0], fps=self._fps)
565+
self.reporter.log_info(f"Getting annotations for {generator.frames_count} frames from {self._video_name}.")
552566
if response.errors:
553567
self._response.errors = response.errors
554568
return self._response
555569
if not response.data:
556570
self._response.errors = AppException(f"Video {self._video_name} not found.")
557571
annotations = response.data
558572
if annotations:
559-
self._response.data = list(VideoFrameGenerator(response.data[0], fps=self._fps))
573+
self._response.data = list(generator)
560574
else:
561575
self._response.data = []
562576
return self._response

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import copy
22
from collections import defaultdict
3-
from typing import Iterable
43
from typing import List
54
from typing import Type
65

src/superannotate/lib/core/video_convertor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, annotation_data: dict, fps: int):
4141
self.fps = fps
4242
self.ratio = 1000 * 1000 / fps
4343
self._frame_id = 1
44-
self._frames_count = self.duration * fps
44+
self.frames_count = self.duration * fps
4545
self.annotations: dict = {}
4646
self._mapping = {}
4747
self._process()
@@ -141,5 +141,5 @@ def _process(self):
141141
)
142142

143143
def __iter__(self):
144-
for frame_no in range(1, int(self._frames_count) + 1):
144+
for frame_no in range(1, int(self.frames_count) + 1):
145145
yield self.get_frame(frame_no).dict()

0 commit comments

Comments
 (0)