Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/superannotate/lib/app/interface/sdk_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,7 @@ def delete_annotations(

:param project: project name or folder path (e.g., "project1/folder1")
:type project: str
:param item_names: image names. If None, all image annotations from a given project/folder will be deleted.
:param item_names: item names. If None, all the items in the specified directory will be deleted.
:type item_names: list of strs
"""

Expand Down Expand Up @@ -2192,7 +2192,7 @@ def get_annotations(
:param project: project name or folder path (e.g., “project1/folder1”).
:type project: str

:param items: item names. If None all items in specified directory
:param items: item names. If None, all the items in the specified directory will be used.
:type items: list of strs

:return: list of annotations
Expand Down Expand Up @@ -2232,7 +2232,7 @@ def get_annotations_per_frame(
return response.data

def upload_priority_scores(self, project: NotEmptyStr, scores: List[PriorityScore]):
"""Returns per frame annotations for the given video.
"""Upload priority scores for the given list of items.

:param project: project name or folder path (e.g., “project1/folder1”)
:type project: str
Expand Down Expand Up @@ -2673,7 +2673,7 @@ def set_annotation_statuses(
♦ “Skipped” \n
:type annotation_status: str

:param items: item names to set the mentioned status for. If None, all the items in the project will be used.
:param items: item names. If None, all the items in the specified directory will be used.
:type items: list of strs
"""

Expand Down
2 changes: 1 addition & 1 deletion src/superannotate/lib/infrastructure/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ def __init__(self, config: ConfigEntity):
)

self.service_provider = ServiceProvider(http_client)
self._team = self.get_team().data
self._user = self.get_current_user()
self._team = self.get_team().data
self.annotation_classes = AnnotationClassManager(self.service_provider)
self.projects = ProjectManager(self.service_provider)
self.folders = FolderManager(self.service_provider)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from superannotate.lib.infrastructure.validators import validators
25 changes: 18 additions & 7 deletions tests/unit/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ def test_init_via_invalid_token(self):
with self.assertRaisesRegexp(AppException, r"(\s+)token(\s+)Invalid token."):
SAClient(token=_token)

@patch("lib.infrastructure.controller.Controller.get_current_user")
@patch("lib.core.usecases.GetTeamUseCase")
def test_init_via_token(self, get_team_use_case):
def test_init_via_token(self, get_team_use_case, get_current_user):
sa = SAClient(token=self._token)
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int(
self._token.split("=")[-1]
)
assert get_current_user.call_count == 1
assert sa.controller._config.API_TOKEN == self._token
assert sa.controller._config.API_URL == constants.BACKEND_URL

@patch("lib.infrastructure.controller.Controller.get_current_user")
@patch("lib.core.usecases.GetTeamUseCase")
def test_init_via_config_json(self, get_team_use_case):
def test_init_via_config_json(self, get_team_use_case, get_current_user):
with tempfile.TemporaryDirectory() as config_dir:
config_ini_path = f"{config_dir}/config.ini"
config_json_path = f"{config_dir}/config.json"
Expand All @@ -40,11 +43,13 @@ def test_init_via_config_json(self, get_team_use_case):
json.dump({"token": self._token}, config_json)
for kwargs in ({}, {"config_path": f"{config_dir}/config.json"}):
sa = SAClient(**kwargs)

assert sa.controller._config.API_TOKEN == self._token
assert sa.controller._config.API_URL == constants.BACKEND_URL
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int(
self._token.split("=")[-1]
)
assert get_current_user.call_count == 2

def test_init_via_config_json_invalid_json(self):
with tempfile.TemporaryDirectory() as config_dir:
Expand All @@ -61,8 +66,9 @@ def test_init_via_config_json_invalid_json(self):
):
SAClient(**kwargs)

@patch("lib.infrastructure.controller.Controller.get_current_user")
@patch("lib.core.usecases.GetTeamUseCase")
def test_init_via_config_ini(self, get_team_use_case):
def test_init_via_config_ini(self, get_team_use_case, get_current_user):
with tempfile.TemporaryDirectory() as config_dir:
config_ini_path = f"{config_dir}/config.ini"
config_json_path = f"{config_dir}/config.json"
Expand All @@ -85,9 +91,11 @@ def test_init_via_config_ini(self, get_team_use_case):
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int(
self._token.split("=")[-1]
)
assert get_current_user.call_count == 2

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

@patch("lib.core.usecases.GetTeamUseCase")
@patch("lib.infrastructure.controller.Controller.get_current_user")
@patch("lib.infrastructure.controller.Controller.get_team")
@patch.dict(os.environ, {"SA_URL": "SOME_URL", "SA_TOKEN": "SOME_TOKEN=123"})
def test_init_env(self, get_team_use_case):
def test_init_env(self, get_team, get_current_user):
sa = SAClient()
assert sa.controller._config.API_TOKEN == "SOME_TOKEN=123"
assert sa.controller._config.API_URL == "SOME_URL"
assert get_team_use_case.call_args_list[0].kwargs["team_id"] == 123
assert get_team.call_count == 1
assert get_current_user.call_count == 1

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