Skip to content

Commit 8f61bd8

Browse files
committed
Fix tests.
1 parent e22a863 commit 8f61bd8

File tree

16 files changed

+42
-29
lines changed

16 files changed

+42
-29
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
minversion = 3.0
33
log_cli=true
44
python_files = test_*.py
5-
;addopts = -n auto --dist=loadscope
5+
;addopts = -n auto --dist=loads cope

src/superannotate/lib/app/analytics/aggregators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import copy
22
import json
3-
from dataclasses import dataclass
43
from pathlib import Path
54
from typing import List
65
from typing import Optional
76
from typing import Union
87

98
import lib.core as constances
109
import pandas as pd
10+
from dataclasses import dataclass
1111
from lib.app.exceptions import AppException
1212
from lib.core import ATTACHED_VIDEO_ANNOTATION_POSTFIX
1313
from lib.core import PIXEL_ANNOTATION_POSTFIX

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,8 @@ def add_annotation_bbox_to_image(
23342334
response = controller.get_image_annotations(
23352335
project_name=project_name, folder_name=folder_name, image_name=image_name
23362336
)
2337+
if response.errors:
2338+
raise AppException(response.errors)
23372339
annotations = response.data["annotation_json"]
23382340
annotations = add_annotation_bbox_to_json(
23392341
annotations,
@@ -2380,6 +2382,8 @@ def add_annotation_point_to_image(
23802382
response = controller.get_image_annotations(
23812383
project_name=project_name, folder_name=folder_name, image_name=image_name
23822384
)
2385+
if response.errors:
2386+
raise AppException(response.errors)
23832387
annotations = response.data["annotation_json"]
23842388
annotations = add_annotation_point_to_json(
23852389
annotations,
@@ -2423,6 +2427,8 @@ def add_annotation_comment_to_image(
24232427
response = controller.get_image_annotations(
24242428
project_name=project_name, folder_name=folder_name, image_name=image_name
24252429
)
2430+
if response.errors:
2431+
raise AppException(response.errors)
24262432
annotations = response.data["annotation_json"]
24272433
annotations = add_annotation_comment_to_json(
24282434
annotations,

src/superannotate/lib/core/entities/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
from superannotate_schemas.schemas.internal.pixel import PixelAnnotation
1616
from superannotate_schemas.schemas.internal.vector import VectorAnnotation
1717
from superannotate_schemas.schemas.internal.video import VideoAnnotation
18-
from superannotate_schemas.schemas.internal.video import VideoAnnotation as VideoExportAnnotation
18+
from superannotate_schemas.schemas.internal.video import (
19+
VideoAnnotation as VideoExportAnnotation,
20+
)
1921

2022
__all__ = [
2123
"BaseEntity",

src/superannotate/lib/core/reporter.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,12 @@ def start_progress(
4646

4747
@staticmethod
4848
def get_progress_bar(
49-
iterations: Union[int, range], description: str = "Processing", disable=False
49+
iterations: Union[int, range], description: str = "Processing", disable=False
5050
):
5151
if isinstance(iterations, range):
52-
return tqdm.tqdm(
53-
iterations, desc=description, disable=disable
54-
)
52+
return tqdm.tqdm(iterations, desc=description, disable=disable)
5553
else:
56-
return tqdm.tqdm(
57-
total=iterations, desc=description, disable=disable
58-
)
54+
return tqdm.tqdm(total=iterations, desc=description, disable=disable)
5955

6056
def finish_progress(self):
6157
self.progress_bar.close()
@@ -80,7 +76,7 @@ def messages(self):
8076
yield f"{key} [{', '.join(values)}]"
8177

8278

83-
class Progress(object):
79+
class Progress:
8480
def __init__(self, iterations: Union[int, range], description: str = "Processing"):
8581
self._iterations = iterations
8682
self._description = description
@@ -95,5 +91,7 @@ def __exit__(self, type, value, traceback):
9591

9692
def update(self, value=1):
9793
if not self._progress_bar:
98-
self._progress_bar = Reporter.get_progress_bar(self._iterations, self._description)
99-
self._progress_bar.update(value)
94+
self._progress_bar = Reporter.get_progress_bar(
95+
self._iterations, self._description
96+
)
97+
self._progress_bar.update(value)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from lib.core.usecases.base import BaseReportableUseCae
2626
from lib.core.usecases.images import GetBulkImages
2727
from lib.core.usecases.images import ValidateAnnotationUseCase
28-
from superannotate_schemas.validators import AnnotationValidators
2928
from superannotate.logger import get_default_logger
29+
from superannotate_schemas.validators import AnnotationValidators
3030

3131
logger = get_default_logger()
3232

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
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 Progress
3839
from lib.core.reporter import Reporter
3940
from lib.core.repositories import BaseManageableRepository
4041
from lib.core.repositories import BaseReadOnlyRepository
4142
from lib.core.response import Response
42-
from lib.core.reporter import Progress
4343
from lib.core.serviceproviders import SuerannotateServiceProvider
4444
from lib.core.usecases.base import BaseInteractiveUseCase
4545
from lib.core.usecases.base import BaseReportableUseCae
@@ -3208,7 +3208,9 @@ def execute(self) -> Response:
32083208
image_quality_in_editor=self._image_quality_in_editor,
32093209
)
32103210
if not frames_generator_use_case.is_valid():
3211-
self._response.errors = use_case.response.errors
3211+
self._response.errors = (
3212+
frames_generator_use_case.response.errors
3213+
)
32123214
return self._response
32133215

32143216
frames_generator = frames_generator_use_case.execute()
@@ -3230,7 +3232,9 @@ def execute(self) -> Response:
32303232
if set(duplicate_images) == set(frame_names):
32313233
continue
32323234
uploaded_paths = []
3233-
with Progress(total_frames_count, f"Uploading {Path(path).name}") as progress:
3235+
with Progress(
3236+
total_frames_count, f"Uploading {Path(path).name}"
3237+
) as progress:
32343238
for _ in frames_generator:
32353239
use_case = UploadImagesFromFolderToProject(
32363240
project=self._project,

src/superannotate/lib/infrastructure/controller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
from lib.infrastructure.repositories import TeamRepository
3333
from lib.infrastructure.repositories import WorkflowRepository
3434
from lib.infrastructure.services import SuperannotateBackendService
35-
from superannotate_schemas.validators import AnnotationValidators
3635
from superannotate.logger import get_default_logger
36+
from superannotate_schemas.validators import AnnotationValidators
37+
3738

3839
class SingleInstanceMetaClass(type):
3940
_instances = {}

tests/integration/aggregations/test_video_annotation_to_df.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from unittest import TestCase
88

99
import src.superannotate as sa
10+
from src.superannotate.logger import get_default_logger
1011

1112

1213
class TestAggregateVideoAnnotation(TestCase):
@@ -41,7 +42,7 @@ def test_nested_folder_data_filling(self):
4142
def test_empty_folder_log(self):
4243
with tempfile.TemporaryDirectory() as temp_dir:
4344
copy_tree(f"{self.folder_path}/classes", f"{temp_dir}/classes")
44-
logger = logging.getLogger('root')
45+
logger = get_default_logger()
4546
with mock.patch.object(logger, 'warning') as mock_log:
4647
_ = sa.aggregate_annotations_as_df(temp_dir, self.PROJECT_TYPE)
4748
mock_log.assert_called_with(f"Could not find annotations in {temp_dir}.")

tests/integration/test_assign_images.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import pytest
23
from os.path import dirname
34

45
import src.superannotate as sa
@@ -55,6 +56,7 @@ def test_assign_images_folder(self):
5556
self.assertIsNotNone(im1_metadata["qa_name"])
5657
self.assertIsNotNone(im2_metadata["qa_name"])
5758

59+
@pytest.mark.flaky(reruns=2)
5860
def test_un_assign_images(self):
5961

6062
email = sa.get_team_metadata()["users"][0]["email"]

0 commit comments

Comments
 (0)