Skip to content

Commit f34e46f

Browse files
committed
no more Skippable exceptions, deprecation messages and more
1 parent 98c3679 commit f34e46f

File tree

6 files changed

+28
-30
lines changed

6 files changed

+28
-30
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ def __init__(
4646
f"CLI's superannotate init to generate default location config file."
4747
)
4848
config_repo = ConfigRepository(config_path)
49+
main_endpoint = config_repo.get_one("main_endpoint").value
50+
if not main_endpoint:
51+
main_endpoint = constants.BACKEND_URL
4952
token, host, ssl_verify = (
5053
Controller.validate_token(config_repo.get_one("token").value),
51-
config_repo.get_one("main_endpoint").value,
54+
main_endpoint,
5255
config_repo.get_one("ssl_verify").value,
5356
)
5457
self._host = host
@@ -57,19 +60,13 @@ def __init__(
5760
BaseInterfaceFacade.REGISTRY.append(self)
5861

5962
@property
60-
@abstractmethod
6163
def host(self):
62-
raise NotImplementedError
64+
return self._host
6365

6466
@property
65-
@abstractmethod
6667
def token(self):
67-
raise NotImplementedError
68+
return self._token
6869

69-
@property
70-
@abstractmethod
71-
def logger(self):
72-
raise NotImplementedError
7370

7471

7572
class Tracker:

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,10 +693,9 @@ def assign_items(
693693

694694
if not response.errors:
695695
logger.info(f"Assign items to user {user}")
696-
elif response.status != "Skip":
696+
else:
697697
raise AppException(response.errors)
698698

699-
@validate_arguments
700699
def unassign_items(
701700
self, project: Union[NotEmptyStr, dict], item_names: List[NotEmptyStr]
702701
):
@@ -731,6 +730,14 @@ def assign_images(
731730
:param user: user email
732731
:type user: str
733732
"""
733+
734+
warning_msg = (
735+
"We're deprecating the assign_images function. Please use assign_items instead."
736+
"Learn more. \n"
737+
"https://superannotate.readthedocs.io/en/stable/superannotate.sdk.html#superannotate.assign_items"
738+
)
739+
logger.warning(warning_msg)
740+
warnings.warn(warning_msg, DeprecationWarning)
734741
project_name, folder_name = extract_project_folder(project)
735742
project = self.controller.get_project_metadata(project_name).data
736743

@@ -778,6 +785,14 @@ def unassign_images(
778785
:param image_names: list of images to unassign
779786
:type image_names: list of str
780787
"""
788+
789+
warning_msg = (
790+
"We're deprecating the unassign_images function. Please use unassign_items instead."
791+
"Learn more. \n"
792+
"https://superannotate.readthedocs.io/en/stable/superannotate.sdk.html#superannotate.unassign_items"
793+
)
794+
logger.warning(warning_msg)
795+
warnings.warn(warning_msg, DeprecationWarning)
781796
project_name, folder_name = extract_project_folder(project)
782797

783798
response = self.controller.un_assign_items(

src/superannotate/lib/core/exceptions.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ class AppValidationException(AppException):
2525
"""
2626

2727

28-
class SkippableAppValidationException(AppValidationException):
29-
"""
30-
App validation exception
31-
"""
32-
3328
class ImageProcessingException(AppException):
3429
"""
3530
App validation exception

src/superannotate/lib/core/reporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def __exit__(self, type, value, traceback):
4545

4646
def __del__(self):
4747
globs = globals()
48-
if "SESSIONS" in globs and globs["SESSIONS"].get(self.pk):
49-
del globs["SESSIONS"][self.pk]
48+
# if "SESSIONS" in globs and globs.get("SESSIONS", {}).get(self.pk):
49+
# del globs["SESSIONS"][self.pk]
5050

5151
@property
5252
def data(self):

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Iterable
55
from typing import List
66

7-
from lib.core.exceptions import AppValidationException, SkippableAppValidationException
7+
from lib.core.exceptions import AppValidationException
88
from lib.core.reporter import Reporter
99
from lib.core.response import Response
1010

@@ -24,9 +24,6 @@ def _validate(self):
2424
if name.startswith("validate_"):
2525
method = getattr(self, name)
2626
method()
27-
except SkippableAppValidationException as e:
28-
self._response.errors = e
29-
self._response.status = 'Skip'
3027
except AppValidationException as e:
3128
self._response.errors = e
3229

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from lib.core.entities import TmpImageEntity
1313
from lib.core.entities import VideoEntity
1414
from lib.core.exceptions import AppException
15-
from lib.core.exceptions import AppValidationException, SkippableAppValidationException
15+
from lib.core.exceptions import AppValidationException
1616
from lib.core.exceptions import BackendError
1717
from lib.core.reporter import Reporter
1818
from lib.core.repositories import BaseReadOnlyRepository
@@ -215,11 +215,7 @@ def validate_user(self, ):
215215
if c["user_id"] == self._user:
216216
return True
217217

218-
logger.warning(
219-
f"Skipping {self._user}. {self._user} is not a verified contributor for the {self._project.name}"
220-
)
221-
222-
raise SkippableAppValidationException(f"{self._user} is not a verified contributor for the {self._project.name}")
218+
raise AppValidationException(f"{self._user} is not a verified contributor for the {self._project.name}")
223219

224220
def execute(self):
225221
if self.is_valid():
@@ -236,8 +232,6 @@ def execute(self):
236232
f"Cant assign {', '.join(self._item_names[i: i + self.CHUNK_SIZE])}"
237233
)
238234
continue
239-
else:
240-
self._response.status = 'Ok'
241235
return self._response
242236

243237

0 commit comments

Comments
 (0)