Skip to content

Architecture refactoring#56

Merged
l-golofastov merged 16 commits intomainfrom
refactor/architecture-refactoring
Jun 5, 2025
Merged

Architecture refactoring#56
l-golofastov merged 16 commits intomainfrom
refactor/architecture-refactoring

Conversation

@l-golofastov
Copy link
Contributor

@l-golofastov l-golofastov commented Jun 3, 2025

Summary

Architecture refactoring.

Solve the issue: #55

Quick changelog

  • Add PySATL-Criterion as a dependency
  • New database models (Experiment configs, random values, powers, time complexity)
  • Worker models
  • Report builder models
  • Experiment step models
  • Abstract experiment factory

What's new?

Framework architecture refactoring. Previous functionality left unchanged.

Copy link
Contributor

@f1i3g3 f1i3g3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хочется, чтобы все еще раз увидели общую диаграмму - из неё следуют важные классы (без неё вообще не понять, что откуда и почему.
Так вроде всё ок.

Copy link
Contributor

@f1i3g3 f1i3g3 Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мб какой-то коммент на будущее оставить для расширения?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для остальных перечислений так же.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не понял, Дим, что ты имеешь в виду.

"""


class CriticalValueExecutionStep:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не нужно ли добавить общий ExecutionStep?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Он есть, это IExperimentStep. Он объявлен как Protocol, в котором задан метод run() c определенной сигнатурой. CriticalValueExecutionStep реализует данный метод с такой же сигнатурой, что означает, что он является подклассом IExperimentStep (duck typing). Можно было бы явно указать, но это не требуется.

Copy link
Contributor

@f1i3g3 f1i3g3 Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично для других шагов.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, для них работает то же самое правило.

Comment on lines +7 to +9
G = TypeVar("G", covariant=True, bound=IExperimentStep)
E = TypeVar("E", covariant=True, bound=IExperimentStep)
R = TypeVar("R", covariant=True, bound=IExperimentStep)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это же во всех версиях Питона будет работать?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Начиная с 3.5 -- да

Copy link
Contributor

@f1i3g3 f1i3g3 Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут, как я понимаю, интерфейс обращения к бд.

Copy link
Contributor

@f1i3g3 f1i3g3 Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Его бы отдельно вынести.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это не интерфейс, а конкретная пустая (пока что) реализация.

Comment on lines +30 to +44
@dataclass
class ExperimentQuery(DataQuery):
experiment_type: str
storage_connection: str
run_mode: str
hypothesis: str
data_generator_type: str
executor_type: str
report_builder_type: str
sample_sizes: list[int]
monte_carlo_count: int
criteria: dict[str, list[float]]
alternatives: dict[str, list[float]]
significance_levels: list[float]

Copy link
Contributor

@f1i3g3 f1i3g3 Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мб в разные файлы вынести? Хотя я слишком докапываюсь.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было бы, но мне показалось, что этим классам логичнее лежать вместе

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну точно отдельный интерфейс для бд нужен!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Интерфейсы для каждой бд есть (например, для SQLitePowerStorage -- IPowerStorage). Я не указал явное унаследование, поскольку все интерфейсы -- это Protocol. Однако интерфейсы для бд параметризуются конкретным типов, что хуже тайпчекается, поэтому добавил явное наследование, чтобы питону было чуть легче.

@l-golofastov l-golofastov merged commit 3c675f9 into main Jun 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants