-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c38662
commit b3e5e72
Showing
30 changed files
with
257 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from datetime import datetime | ||
from enum import StrEnum, auto | ||
from uuid import UUID, uuid4 | ||
from sqlalchemy import ForeignKey | ||
from sqlalchemy.dialects.postgresql import JSONB | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
from app.db import Base | ||
|
||
|
||
class TaskStatus(StrEnum): | ||
IN_PROCESS = auto() | ||
COMPLETED = auto() | ||
INTERNAL_SERVER_ERROR = auto() | ||
RESOURCE_LIMIT_IS_REACHED = auto() | ||
ADDED_TO_THE_TASK_QUEUE = auto() | ||
ADDING_TO_DB = auto() | ||
|
||
|
||
class Task(Base): | ||
__tablename__ = "Task" | ||
|
||
id: Mapped[UUID] = mapped_column(primary_key=True, default=uuid4) | ||
user_id: Mapped[UUID | None] = mapped_column( | ||
ForeignKey("User.id", ondelete="SET NULL", onupdate="CASCADE") | ||
) | ||
file_id: Mapped[UUID | None] = mapped_column( | ||
ForeignKey("FileInfo.id", ondelete="SET NULL", onupdate="CASCADE") | ||
) | ||
is_private: Mapped[bool] = mapped_column(default=False) | ||
attempt_number: Mapped[int] = mapped_column(default=0) | ||
status: Mapped[TaskStatus] | ||
phase_name: Mapped[str | None] = mapped_column(default=None) | ||
current_phase: Mapped[int | None] = mapped_column(default=None) | ||
progres: Mapped[float] = mapped_column(default=0) | ||
max_phase: Mapped[int | None] = mapped_column(default=None) | ||
error_msg: Mapped[int | None] = mapped_column(default=None) | ||
id_executed: Mapped[bool] = mapped_column(default=False) | ||
elapsed_time: Mapped[float | None] = mapped_column(default=None) | ||
config: Mapped[dict] = mapped_column(JSONB) | ||
result: Mapped[dict] = mapped_column(JSONB) | ||
created_at: Mapped[datetime] | ||
deleted_at: Mapped[datetime | None] = mapped_column(default=None) | ||
|
||
user = relationship("User") | ||
file_info = relationship("FileInfo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from typing import Annotated | ||
from pydantic import Field | ||
from app.domain.task.schema.base_config import BaseTaskConfig | ||
|
||
|
||
class ARTaskConfig(BaseTaskConfig): | ||
min_support_ar: Annotated[float, Field(ge=0, le=1)] | ||
min_confidence: Annotated[float, Field(ge=0, le=1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from app.domain.task.schema.specific_with_deps_result import SpecificTaskWithDepsResult | ||
|
||
|
||
class ARTaskResult(SpecificTaskWithDepsResult): | ||
value_dictionary: dict[int, int] | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from enum import StrEnum, auto | ||
from pydantic import BaseModel | ||
|
||
|
||
class DBTaskPrimitiveType(StrEnum): | ||
AR = auto() | ||
CFD = auto() | ||
FD = auto() | ||
TypoFD = auto() | ||
TypoCluster = auto() | ||
SpecificTypoCluster = auto() | ||
Stats = auto() | ||
|
||
|
||
class BaseTaskConfig(BaseModel): | ||
algorithm_name: str | ||
primitive_type: DBTaskPrimitiveType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from datetime import datetime | ||
from pydantic import BaseModel | ||
|
||
|
||
class BaseTaskResult(BaseModel): | ||
created_at: datetime | ||
deleted_at: datetime | None = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from typing import Annotated | ||
from pydantic import Field | ||
from app.domain.task.schema.base_config import BaseTaskConfig | ||
|
||
|
||
class CFDTaskConfig(BaseTaskConfig): | ||
max_lhs: Annotated[int, Field(ge=1, le=10)] | ||
min_support_cfd: Annotated[int, Field(ge=1, le=16)] | ||
min_confidence: Annotated[float, Field(ge=0, le=1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from app.domain.task.schema.specific_with_deps_result import SpecificTaskWithDepsResult | ||
|
||
|
||
class CFDTaskResult(SpecificTaskWithDepsResult): | ||
pk_column_indices: list[int] | None | ||
with_patterns: str | None | ||
without_patterns: str | None | ||
value_dictionary: dict[int, int] | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from typing import Annotated | ||
from pydantic import Field | ||
from app.domain.task.schema.base_config import BaseTaskConfig | ||
|
||
|
||
class FDTaskConfig(BaseTaskConfig): | ||
error_threshold: Annotated[float, Field(ge=0, le=1)] | ||
max_lhs: Annotated[int, Field(ge=1, le=10)] | ||
threads_count: Annotated[int, Field(ge=1, le=8)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from app.domain.task.schema.specific_with_deps_result import SpecificTaskWithDepsResult | ||
|
||
|
||
class FDTaskResult(SpecificTaskWithDepsResult): | ||
pk_column_indices: list[int] | None | ||
without_patterns: str | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from enum import StrEnum, auto | ||
from app.domain.task.schema.base_config import BaseTaskConfig | ||
|
||
|
||
class MFDMetrics(StrEnum): | ||
EUCLIDEAN = auto() | ||
LEVENSHTEIN = auto() | ||
MODULUS_OF_DIFFERENCE = auto() | ||
|
||
|
||
class MFDMetricAlgorithm(StrEnum): | ||
BRUTE = auto() | ||
APPROX = auto() | ||
CALIPERS = auto() | ||
|
||
|
||
class MFDTaskConfig(BaseTaskConfig): | ||
tolerance_parametr: float | ||
lhs_indices: list[int] | ||
rhs_indices: list[int] | ||
distance_to_null_is_infinity: bool | ||
type_of_metric: MFDMetrics | ||
q_gram_length: int | ||
metric_algorithm: MFDMetricAlgorithm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from app.domain.task.schema.specific_with_deps_result import SpecificTaskWithDepsResult | ||
|
||
|
||
class MFDTaskResult(SpecificTaskWithDepsResult): | ||
is_holding: bool | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from pydantic import UUID4 | ||
from app.domain.task.schema.base_config import BaseTaskConfig | ||
|
||
|
||
class SpecificTypoClusterTaskConfig(BaseTaskConfig): | ||
parent_task_id: UUID4 | ||
cluster_id: UUID4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from enum import StrEnum, auto | ||
from app.domain.task.schema.base_result import BaseTaskResult | ||
|
||
|
||
class SquashState(StrEnum): | ||
SQUASHED = auto() | ||
NOT_SQUASHED = auto() | ||
|
||
|
||
class SpecificTypoClusterTaskResult(BaseTaskResult): | ||
suspicious_indices: list[int] | None | ||
sguash_state: SquashState | ||
sorted_cluster: str | None | ||
not_sorted_cluster: str | None | ||
items_amount: int | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from app.domain.task.schema.base_result import BaseTaskResult | ||
|
||
|
||
class SpecificTaskWithDepsResult(BaseTaskResult): | ||
deps: str | None | ||
deps_amount: int | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from typing import Annotated | ||
from pydantic import Field | ||
from app.domain.task.schema.base_config import BaseTaskConfig | ||
|
||
|
||
class StatsTaskConfig(BaseTaskConfig): | ||
threads_count: Annotated[int, Field(ge=1, le=8)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from app.domain.task.schema.base_result import BaseTaskResult | ||
|
||
|
||
class StatsTaskResult(BaseTaskResult): | ||
column_index: int | ||
type: str | ||
distinct: int | None | ||
is_categorical: bool | None | ||
count: int | None | ||
avg: str | None | ||
std: str | None | ||
skewness: str | None | ||
kurtosis: str | None | ||
min: str | None | ||
max: str | None | ||
sum: str | None | ||
quantile25: str | None | ||
quantile50: str | None | ||
quantile75: str | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from dataclasses import Field | ||
from typing import Annotated | ||
|
||
from pydantic import UUID4, BaseModel | ||
|
||
from app.domain.task.schema.base_config import BaseTaskConfig | ||
|
||
|
||
class TypoFD(BaseModel): | ||
left: list[int] | ||
right: int | ||
|
||
|
||
class TypoClusterTaskConfig(BaseTaskConfig): | ||
parent_task_id: UUID4 | ||
typo_fd: TypoFD | ||
radius: Annotated[float, Field(ge=1, le=10)] | ||
ratio: Annotated[float, Field(ge=0, le=1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from app.domain.task.schema.base_result import BaseTaskResult | ||
|
||
|
||
class TypoClusterTaskResult(BaseTaskResult): | ||
typo_clusters: str | None | ||
suspicious_indices: list[int] | None | ||
clusters_count: int | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from enum import StrEnum, auto | ||
from typing import Annotated | ||
from pydantic import Field | ||
from app.domain.task.schema.base_config import BaseTaskConfig | ||
|
||
|
||
class MetricType(StrEnum): | ||
LEVENSHTEIN = auto() | ||
MODULUS_OF_DIFFERENCE = auto() | ||
|
||
|
||
class TypoFDTaskConfig(BaseTaskConfig): | ||
error_threshold: Annotated[float, Field(ge=0, le=1)] | ||
max_lhs: Annotated[int, Field(ge=1, le=9)] | ||
threads_count: Annotated[int, Field(ge=1, le=8)] | ||
precise_algorithm: str | ||
approximate_algorithm: str | ||
type_of_metric: MetricType | ||
default_radius: Annotated[float, Field(ge=1, le=10)] | ||
default_ratio: Annotated[float, Field(ge=0, le=1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from app.domain.task.schema.specific_with_deps_result import SpecificTaskWithDepsResult | ||
|
||
|
||
class TypoFDTaskResult(SpecificTaskWithDepsResult): | ||
pk_column_indices: list[int] | None |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.