Skip to content

Commit

Permalink
chore: incorrect algo exception
Browse files Browse the repository at this point in the history
  • Loading branch information
vladyoslav committed Oct 28, 2024
1 parent 37314bd commit f6424ae
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 23 deletions.
11 changes: 3 additions & 8 deletions internal/domain/task/entities/afd/afd_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
from desbordante.afd.algorithms import Pyro, Tane

from internal.domain.task.entities.task import Task
from internal.domain.task.value_objects import PrimitiveName
from internal.domain.task.value_objects import PrimitiveName, IncorrectAlgorithmName

from internal.domain.task.value_objects.afd import AfdTaskResult, AfdTaskConfig
from internal.domain.task.value_objects.afd import (
AfdAlgoName,
AfdAlgoResult,
FdModel,
IncorrectAFDAlgorithmName,
)
from internal.domain.task.value_objects.afd import AfdAlgoName, AfdAlgoResult, FdModel


class AfdTask(Task[FdAlgorithm, AfdTaskConfig, AfdTaskResult]):
Expand Down Expand Up @@ -56,4 +51,4 @@ def _match_algo_by_name(self, algo_name: str) -> FdAlgorithm:
case AfdAlgoName.Tane:
return Tane()
case _:
raise IncorrectAFDAlgorithmName(algo_name)
raise IncorrectAlgorithmName(algo_name, "AFD")
5 changes: 2 additions & 3 deletions internal/domain/task/entities/fd/fd_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
)

from internal.domain.task.entities.task import Task
from internal.domain.task.value_objects import PrimitiveName
from internal.domain.task.value_objects import PrimitiveName, IncorrectAlgorithmName
from internal.domain.task.value_objects.fd import FdTaskConfig, FdTaskResult
from internal.domain.task.value_objects.fd import (
FdAlgoName,
FdModel,
FdAlgoResult,
IncorrectFDAlgorithmName,
)


Expand Down Expand Up @@ -82,4 +81,4 @@ def _match_algo_by_name(self, algo_name: str) -> FdAlgorithm:
case FdAlgoName.Tane:
return Tane()
case _:
raise IncorrectFDAlgorithmName(algo_name)
raise IncorrectAlgorithmName(algo_name, "FD")
4 changes: 4 additions & 0 deletions internal/domain/task/value_objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
TaskFailureReason,
)

from internal.domain.task.value_objects.incorrect_algo_exception import ( # noqa: F401
IncorrectAlgorithmName,
)

OneOfTaskConfig = Annotated[
Union[
FdTaskConfig,
Expand Down
3 changes: 0 additions & 3 deletions internal/domain/task/value_objects/afd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
)
from internal.domain.task.value_objects.afd.algo_name import AfdAlgoName # noqa: F401
from internal.domain.task.value_objects.primitive_name import PrimitiveName
from internal.domain.task.value_objects.afd.exception import ( # noqa: F401
IncorrectAFDAlgorithmName,
)


class BaseAfdTaskModel(BaseModel):
Expand Down
3 changes: 0 additions & 3 deletions internal/domain/task/value_objects/afd/exception.py

This file was deleted.

3 changes: 0 additions & 3 deletions internal/domain/task/value_objects/fd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
FdModel,
)
from internal.domain.task.value_objects.fd.algo_name import FdAlgoName # noqa: F401
from internal.domain.task.value_objects.fd.exception import ( # noqa: F401
IncorrectFDAlgorithmName,
)


class BaseFdTaskModel(BaseModel):
Expand Down
3 changes: 0 additions & 3 deletions internal/domain/task/value_objects/fd/exception.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class IncorrectAlgorithmName(Exception):
def __init__(self, algo: str, primitive: str):
super().__init__(f"{algo} is incorrect {primitive} algorithm name")

0 comments on commit f6424ae

Please sign in to comment.