Skip to content

Commit 4c8b592

Browse files
authored
Merge pull request #602 from superannotateai/minor_updates
doc string updates
2 parents 0415f81 + 31f6b95 commit 4c8b592

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ def delete_annotations(
20872087
20882088
:param project: project name or folder path (e.g., "project1/folder1")
20892089
:type project: str
2090-
:param item_names: image names. If None, all image annotations from a given project/folder will be deleted.
2090+
:param item_names: item names. If None, all the items in the specified directory will be deleted.
20912091
:type item_names: list of strs
20922092
"""
20932093

@@ -2192,7 +2192,7 @@ def get_annotations(
21922192
:param project: project name or folder path (e.g., “project1/folder1”).
21932193
:type project: str
21942194
2195-
:param items: item names. If None all items in specified directory
2195+
:param items: item names. If None, all the items in the specified directory will be used.
21962196
:type items: list of strs
21972197
21982198
:return: list of annotations
@@ -2232,7 +2232,7 @@ def get_annotations_per_frame(
22322232
return response.data
22332233

22342234
def upload_priority_scores(self, project: NotEmptyStr, scores: List[PriorityScore]):
2235-
"""Returns per frame annotations for the given video.
2235+
"""Upload priority scores for the given list of items.
22362236
22372237
:param project: project name or folder path (e.g., “project1/folder1”)
22382238
:type project: str
@@ -2673,7 +2673,7 @@ def set_annotation_statuses(
26732673
♦ “Skipped” \n
26742674
:type annotation_status: str
26752675
2676-
:param items: item names to set the mentioned status for. If None, all the items in the project will be used.
2676+
:param items: item names. If None, all the items in the specified directory will be used.
26772677
:type items: list of strs
26782678
"""
26792679

src/superannotate/lib/infrastructure/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,8 @@ def __init__(self, config: ConfigEntity):
795795
)
796796

797797
self.service_provider = ServiceProvider(http_client)
798-
self._team = self.get_team().data
799798
self._user = self.get_current_user()
799+
self._team = self.get_team().data
800800
self.annotation_classes = AnnotationClassManager(self.service_provider)
801801
self.projects = ProjectManager(self.service_provider)
802802
self.folders = FolderManager(self.service_provider)

tests/unit/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from superannotate.lib.infrastructure.validators import validators

tests/unit/test_init.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ def test_init_via_invalid_token(self):
1919
with self.assertRaisesRegexp(AppException, r"(\s+)token(\s+)Invalid token."):
2020
SAClient(token=_token)
2121

22+
@patch("lib.infrastructure.controller.Controller.get_current_user")
2223
@patch("lib.core.usecases.GetTeamUseCase")
23-
def test_init_via_token(self, get_team_use_case):
24+
def test_init_via_token(self, get_team_use_case, get_current_user):
2425
sa = SAClient(token=self._token)
2526
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int(
2627
self._token.split("=")[-1]
2728
)
29+
assert get_current_user.call_count == 1
2830
assert sa.controller._config.API_TOKEN == self._token
2931
assert sa.controller._config.API_URL == constants.BACKEND_URL
3032

33+
@patch("lib.infrastructure.controller.Controller.get_current_user")
3134
@patch("lib.core.usecases.GetTeamUseCase")
32-
def test_init_via_config_json(self, get_team_use_case):
35+
def test_init_via_config_json(self, get_team_use_case, get_current_user):
3336
with tempfile.TemporaryDirectory() as config_dir:
3437
config_ini_path = f"{config_dir}/config.ini"
3538
config_json_path = f"{config_dir}/config.json"
@@ -40,11 +43,13 @@ def test_init_via_config_json(self, get_team_use_case):
4043
json.dump({"token": self._token}, config_json)
4144
for kwargs in ({}, {"config_path": f"{config_dir}/config.json"}):
4245
sa = SAClient(**kwargs)
46+
4347
assert sa.controller._config.API_TOKEN == self._token
4448
assert sa.controller._config.API_URL == constants.BACKEND_URL
4549
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int(
4650
self._token.split("=")[-1]
4751
)
52+
assert get_current_user.call_count == 2
4853

4954
def test_init_via_config_json_invalid_json(self):
5055
with tempfile.TemporaryDirectory() as config_dir:
@@ -61,8 +66,9 @@ def test_init_via_config_json_invalid_json(self):
6166
):
6267
SAClient(**kwargs)
6368

69+
@patch("lib.infrastructure.controller.Controller.get_current_user")
6470
@patch("lib.core.usecases.GetTeamUseCase")
65-
def test_init_via_config_ini(self, get_team_use_case):
71+
def test_init_via_config_ini(self, get_team_use_case, get_current_user):
6672
with tempfile.TemporaryDirectory() as config_dir:
6773
config_ini_path = f"{config_dir}/config.ini"
6874
config_json_path = f"{config_dir}/config.json"
@@ -85,9 +91,11 @@ def test_init_via_config_ini(self, get_team_use_case):
8591
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int(
8692
self._token.split("=")[-1]
8793
)
94+
assert get_current_user.call_count == 2
8895

96+
@patch("lib.infrastructure.controller.Controller.get_current_user")
8997
@patch("lib.core.usecases.GetTeamUseCase")
90-
def test_init_via_config_relative_filepath(self, get_team_use_case):
98+
def test_init_via_config_relative_filepath(self, get_team_use_case, get_current_user):
9199
with tempfile.TemporaryDirectory(dir=Path("~").expanduser()) as config_dir:
92100
config_ini_path = f"{config_dir}/config.ini"
93101
config_json_path = f"{config_dir}/config.json"
@@ -113,14 +121,17 @@ def test_init_via_config_relative_filepath(self, get_team_use_case):
113121
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int(
114122
self._token.split("=")[-1]
115123
)
124+
assert get_current_user.call_count == 2
116125

117-
@patch("lib.core.usecases.GetTeamUseCase")
126+
@patch("lib.infrastructure.controller.Controller.get_current_user")
127+
@patch("lib.infrastructure.controller.Controller.get_team")
118128
@patch.dict(os.environ, {"SA_URL": "SOME_URL", "SA_TOKEN": "SOME_TOKEN=123"})
119-
def test_init_env(self, get_team_use_case):
129+
def test_init_env(self, get_team, get_current_user):
120130
sa = SAClient()
121131
assert sa.controller._config.API_TOKEN == "SOME_TOKEN=123"
122132
assert sa.controller._config.API_URL == "SOME_URL"
123-
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == 123
133+
assert get_team.call_count == 1
134+
assert get_current_user.call_count == 1
124135

125136
@patch.dict(os.environ, {"SA_URL": "SOME_URL", "SA_TOKEN": "SOME_TOKEN"})
126137
def test_init_env_invalid_token(self):

0 commit comments

Comments
 (0)