Skip to content

Commit 1a46510

Browse files
committed
@sanderegg review: rename exc
1 parent 3839869 commit 1a46510

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

api/specs/web-server/_projects_states.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pydantic import ValidationError
1414
from servicelib.aiohttp import status
1515
from simcore_service_webserver._meta import API_VTAG
16-
from simcore_service_webserver.director_v2.exceptions import DirectorServiceError
16+
from simcore_service_webserver.director_v2.exceptions import DirectorV2ServiceError
1717
from simcore_service_webserver.projects._controller.projects_states_rest import (
1818
ProjectPathParams,
1919
_OpenProjectQuery,
@@ -62,7 +62,7 @@ def to_desc(exceptions: list[type[Exception]] | type[Exception]):
6262
"description": to_desc([ValidationError])
6363
},
6464
status.HTTP_503_SERVICE_UNAVAILABLE: {
65-
"description": to_desc([DirectorServiceError])
65+
"description": to_desc([DirectorV2ServiceError])
6666
},
6767
},
6868
)

services/web/server/src/simcore_service_webserver/director_v2/_client_base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tenacity.wait import wait_random
1111
from yarl import URL
1212

13-
from .exceptions import DirectorServiceError
13+
from .exceptions import DirectorV2ServiceError
1414
from .settings import get_client_session
1515

1616
log = logging.getLogger(__name__)
@@ -30,7 +30,9 @@
3030
DataBody: TypeAlias = DataType | list[DataType] | None
3131

3232

33-
_StatusToExceptionMapping = dict[int, tuple[type[DirectorServiceError], dict[str, Any]]]
33+
_StatusToExceptionMapping = dict[
34+
int, tuple[type[DirectorV2ServiceError], dict[str, Any]]
35+
]
3436

3537

3638
def _get_exception_from(
@@ -40,7 +42,7 @@ def _get_exception_from(
4042
exc, exc_ctx = on_error[status_code]
4143
return exc(**exc_ctx, status=status_code, reason=reason)
4244
# default
43-
return DirectorServiceError(status=status_code, reason=reason, url=url)
45+
return DirectorV2ServiceError(status=status_code, reason=reason, url=url)
4446

4547

4648
@retry(**DEFAULT_RETRY_POLICY)
@@ -95,14 +97,14 @@ async def request_director_v2(
9597
return payload
9698

9799
except TimeoutError as err:
98-
raise DirectorServiceError(
100+
raise DirectorV2ServiceError(
99101
status=status.HTTP_503_SERVICE_UNAVAILABLE,
100102
reason=f"request to director-v2 timed-out: {err}",
101103
url=url,
102104
) from err
103105

104106
except aiohttp.ClientError as err:
105-
raise DirectorServiceError(
107+
raise DirectorV2ServiceError(
106108
status=status.HTTP_503_SERVICE_UNAVAILABLE,
107109
reason=f"request to director-v2 service unexpected error {err}",
108110
url=url,

services/web/server/src/simcore_service_webserver/director_v2/_controller/_rest_exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from servicelib.aiohttp import status
22
from simcore_service_webserver.constants import MSG_TRY_AGAIN_OR_SUPPORT
3-
from simcore_service_webserver.director_v2.exceptions import DirectorServiceError
3+
from simcore_service_webserver.director_v2.exceptions import DirectorV2ServiceError
44

55
from ...exception_handling import (
66
ExceptionHandlersMap,
@@ -24,7 +24,7 @@
2424
status.HTTP_402_PAYMENT_REQUIRED,
2525
"Wallet does not have enough credits for computations. {reason}",
2626
),
27-
DirectorServiceError: HttpErrorInfo(
27+
DirectorV2ServiceError: HttpErrorInfo(
2828
status.HTTP_503_SERVICE_UNAVAILABLE,
2929
# This error is raised when the director service raises an unhandled exception.
3030
# Most likely the director service is down or misconfigured so the user is asked to try again later.

services/web/server/src/simcore_service_webserver/director_v2/_director_v2_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from ..users.exceptions import UserDefaultWalletNotFoundError
3232
from ..wallets import api as wallets_service
3333
from ._client_base import DataType, request_director_v2
34-
from .exceptions import ComputationNotFoundError, DirectorServiceError
34+
from .exceptions import ComputationNotFoundError, DirectorV2ServiceError
3535
from .settings import DirectorV2Settings, get_plugin_settings
3636

3737
_logger = logging.getLogger(__name__)
@@ -75,7 +75,7 @@ async def create_or_update_pipeline(
7575
assert isinstance(computation_task_out, dict) # nosec
7676
return computation_task_out
7777

78-
except DirectorServiceError as exc:
78+
except DirectorV2ServiceError as exc:
7979
_logger.error( # noqa: TRY400
8080
"could not create pipeline from project %s: %s",
8181
project_id,
@@ -117,7 +117,7 @@ async def get_computation_task(
117117
_logger.debug("found computation task: %s", f"{task_out=}")
118118

119119
return task_out
120-
except DirectorServiceError as exc:
120+
except DirectorV2ServiceError as exc:
121121
if exc.status == status.HTTP_404_NOT_FOUND:
122122
# the pipeline might not exist and that is ok
123123
return None

services/web/server/src/simcore_service_webserver/director_v2/director_v2_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
is_pipeline_running,
1313
stop_pipeline,
1414
)
15-
from .exceptions import DirectorServiceError
15+
from .exceptions import DirectorV2ServiceError
1616

1717
# director-v2 module internal API
1818
__all__: tuple[str, ...] = (
1919
"AbstractProjectRunPolicy",
20-
"DirectorServiceError",
20+
"DirectorV2ServiceError",
2121
"create_or_update_pipeline",
2222
"delete_pipeline",
2323
"get_batch_tasks_outputs",

services/web/server/src/simcore_service_webserver/director_v2/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ..errors import WebServerBaseError
66

77

8-
class DirectorServiceError(WebServerBaseError, RuntimeError):
8+
class DirectorV2ServiceError(WebServerBaseError, RuntimeError):
99
"""Basic exception for errors raised by director-v2"""
1010

1111
msg_template = "Unexpected error: director-v2 returned '{status}', reason '{reason}' after calling '{url}'"
@@ -16,5 +16,5 @@ def __init__(self, *, status: int, reason: str, **ctx: Any) -> None:
1616
self.reason = reason
1717

1818

19-
class ComputationNotFoundError(DirectorServiceError):
19+
class ComputationNotFoundError(DirectorV2ServiceError):
2020
msg_template = "Computation '{project_id}' not found"

services/web/server/src/simcore_service_webserver/projects/_controller/projects_states_rest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from simcore_postgres_database.webserver_models import ProjectType
2121

2222
from ..._meta import API_VTAG as VTAG
23-
from ...director_v2.exceptions import DirectorServiceError
23+
from ...director_v2.exceptions import DirectorV2ServiceError
2424
from ...login.decorators import login_required
2525
from ...notifications import project_logs
2626
from ...products import products_web
@@ -141,7 +141,7 @@ async def open_project(request: web.Request) -> web.Response:
141141

142142
return envelope_json_response(ProjectGet.from_domain_model(project))
143143

144-
except DirectorServiceError as exc:
144+
except DirectorV2ServiceError as exc:
145145
# there was an issue while accessing the director-v2/director-v0
146146
# ensure the project is closed again
147147
await _projects_service.try_close_project_for_user(

0 commit comments

Comments
 (0)