Skip to content

Commit

Permalink
feat(algo): fields descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
vladyoslav committed Oct 28, 2024
1 parent 58b4adb commit a89653e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 38 deletions.
21 changes: 13 additions & 8 deletions internal/domain/task/value_objects/afd/algo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from internal.domain.common import OptionalModel
from internal.domain.task.value_objects.afd.algo_name import AfdAlgoName
from internal.domain.task.value_objects.afd.algo_descriptions import descriptions


class BaseAfdConfig(OptionalModel):
Expand All @@ -14,19 +15,23 @@ class BaseAfdConfig(OptionalModel):
class PyroConfig(BaseAfdConfig):
algo_name: Literal[AfdAlgoName.Pyro]

is_null_equal_null: bool
error: Annotated[float, Field(ge=0, le=1)]
max_lhs: Annotated[int, Field(ge=1, le=10)]
threads: Annotated[int, Field(ge=1, le=8)]
seed: int
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]
error: Annotated[float, Field(ge=0, le=1, description=descriptions["error"])]
threads: Annotated[int, Field(ge=1, le=8, description=descriptions["threads"])]
seed: Annotated[int, Field(description=descriptions["seed"])]


class TaneConfig(BaseAfdConfig):
algo_name: Literal[AfdAlgoName.Tane]

is_null_equal_null: bool
error: Annotated[float, Field(ge=0, le=1)]
max_lhs: Annotated[int, Field(ge=1, le=10)]
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]
error: Annotated[float, Field(ge=0, le=1, description=descriptions["error"])]


OneOfAfdConfig = Annotated[
Expand Down
8 changes: 8 additions & 0 deletions internal/domain/task/value_objects/afd/algo_descriptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
descriptions = {
"max_lhs": "Max considered LHS size",
"is_null_equal_null": "Specify whether two NULLs should be considered equal",
"threads": "Number of threads to use",
"error": "Error threshold value for Approximate FD algorithms",
"error_measure": "PFD error measure to use",
"seed": "RNG seed",
}
81 changes: 51 additions & 30 deletions internal/domain/task/value_objects/fd/algo_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Literal, Annotated, Union

from pydantic import Field

from internal.domain.common import OptionalModel
from internal.domain.task.value_objects.fd.algo_name import FdAlgoName
from internal.domain.task.value_objects.fd.algo_descriptions import descriptions


class BaseFdConfig(OptionalModel):
Expand All @@ -15,84 +14,106 @@ class BaseFdConfig(OptionalModel):
class AidConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.Aid]

max_lhs: Annotated[int, Field(ge=1, le=10)]
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]


class DFDConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.DFD]

max_lhs: Annotated[int, Field(ge=1, le=10)]
is_null_equal_null: bool
threads: Annotated[int, Field(ge=1, le=8)]
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]
threads: Annotated[int, Field(ge=1, le=8, description=descriptions["threads"])]


class DepminerConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.Depminer]

max_lhs: Annotated[int, Field(ge=1, le=10)]
is_null_equal_null: bool
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]


class FDepConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.FDep]

max_lhs: Annotated[int, Field(ge=1, le=10)]
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]


class FUNConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.FUN]

max_lhs: Annotated[int, Field(ge=1, le=10)]
is_null_equal_null: bool
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]


class FastFDsConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.FastFDs]

is_null_equal_null: bool
max_lhs: Annotated[int, Field(ge=1, le=10)]
threads: Annotated[int, Field(ge=1, le=8)]
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]
threads: Annotated[int, Field(ge=1, le=8, description=descriptions["threads"])]


class FdMineConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.FdMine]

max_lhs: Annotated[int, Field(ge=1, le=10)]
is_null_equal_null: bool
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]


class HyFDConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.HyFD]

max_lhs: Annotated[int, Field(ge=1, le=10)]
is_null_equal_null: bool
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]


class PFDTaneConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.PFDTane]

is_null_equal_null: bool
error: Annotated[float, Field(ge=0, le=1)]
error_measure: Annotated[str, Literal["per_tuple", "per_value"]]
max_lhs: Annotated[int, Field(ge=1, le=10)]
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]
error: Annotated[float, Field(ge=0, le=1, description=descriptions["error"])]
error_measure: Annotated[
str,
Literal["per_tuple", "per_value"],
Field(description=descriptions["error_measure"]),
]


class PyroConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.Pyro]

is_null_equal_null: bool
error: Annotated[float, Field(ge=0, le=1)]
max_lhs: Annotated[int, Field(ge=1, le=10)]
threads: Annotated[int, Field(ge=1, le=8)]
seed: int
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]
error: Annotated[float, Field(ge=0, le=1, description=descriptions["error"])]
threads: Annotated[int, Field(ge=1, le=8, description=descriptions["threads"])]
seed: Annotated[int, Field(description=descriptions["seed"])]


class TaneConfig(BaseFdConfig):
algo_name: Literal[FdAlgoName.Tane]

is_null_equal_null: bool
error: Annotated[float, Field(ge=0, le=1)]
max_lhs: Annotated[int, Field(ge=1, le=10)]
max_lhs: Annotated[int, Field(ge=1, le=10, description=descriptions["max_lhs"])]
is_null_equal_null: Annotated[
bool, Field(description=descriptions["is_null_equal_null"])
]
error: Annotated[float, Field(ge=0, le=1, description=descriptions["error"])]


OneOfFdAlgoConfig = Annotated[
Expand Down
8 changes: 8 additions & 0 deletions internal/domain/task/value_objects/fd/algo_descriptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
descriptions = {
"max_lhs": "Max considered LHS size",
"is_null_equal_null": "Specify whether two NULLs should be considered equal",
"threads": "Number of threads to use",
"error": "Error threshold value for Approximate FD algorithms",
"error_measure": "PFD error measure to use",
"seed": "RNG seed",
}

0 comments on commit a89653e

Please sign in to comment.