algomancy-gui 0.3.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. algomancy_gui/__init__.py +0 -0
  2. algomancy_gui/admin_page/__init__.py +1 -0
  3. algomancy_gui/admin_page/admin.py +362 -0
  4. algomancy_gui/admin_page/sessions.py +57 -0
  5. algomancy_gui/appconfiguration.py +291 -0
  6. algomancy_gui/compare_page/__init__.py +1 -0
  7. algomancy_gui/compare_page/compare.py +360 -0
  8. algomancy_gui/compare_page/kpicard.py +236 -0
  9. algomancy_gui/compare_page/scenarioselector.py +99 -0
  10. algomancy_gui/componentids.py +177 -0
  11. algomancy_gui/contentregistry.py +167 -0
  12. algomancy_gui/cqmloader.py +58 -0
  13. algomancy_gui/data_page/__init__.py +1 -0
  14. algomancy_gui/data_page/data.py +77 -0
  15. algomancy_gui/data_page/datamanagementdeletemodal.py +260 -0
  16. algomancy_gui/data_page/datamanagementderivemodal.py +201 -0
  17. algomancy_gui/data_page/datamanagementdownloadmodal.py +193 -0
  18. algomancy_gui/data_page/datamanagementimportmodal.py +438 -0
  19. algomancy_gui/data_page/datamanagementsavemodal.py +191 -0
  20. algomancy_gui/data_page/datamanagementtopbar.py +123 -0
  21. algomancy_gui/data_page/datamanagementuploadmodal.py +366 -0
  22. algomancy_gui/data_page/dialogcallbacks.py +51 -0
  23. algomancy_gui/data_page/filenamematcher.py +109 -0
  24. algomancy_gui/defaultloader.py +36 -0
  25. algomancy_gui/gui_launcher.py +183 -0
  26. algomancy_gui/home_page/__init__.py +1 -0
  27. algomancy_gui/home_page/home.py +16 -0
  28. algomancy_gui/layout.py +199 -0
  29. algomancy_gui/layouthelpers.py +30 -0
  30. algomancy_gui/managergetters.py +28 -0
  31. algomancy_gui/overview_page/__init__.py +1 -0
  32. algomancy_gui/overview_page/overview.py +20 -0
  33. algomancy_gui/py.typed +0 -0
  34. algomancy_gui/scenario_page/__init__.py +0 -0
  35. algomancy_gui/scenario_page/delete_confirmation.py +29 -0
  36. algomancy_gui/scenario_page/new_scenario_creator.py +104 -0
  37. algomancy_gui/scenario_page/new_scenario_parameters_window.py +154 -0
  38. algomancy_gui/scenario_page/scenario_badge.py +36 -0
  39. algomancy_gui/scenario_page/scenario_cards.py +119 -0
  40. algomancy_gui/scenario_page/scenarios.py +596 -0
  41. algomancy_gui/sessionmanager.py +168 -0
  42. algomancy_gui/settingsmanager.py +43 -0
  43. algomancy_gui/stylingconfigurator.py +740 -0
  44. algomancy_gui-0.3.16.dist-info/METADATA +71 -0
  45. algomancy_gui-0.3.16.dist-info/RECORD +46 -0
  46. algomancy_gui-0.3.16.dist-info/WHEEL +4 -0
@@ -0,0 +1,168 @@
1
+ import os
2
+ from typing import Dict, List, TypeVar, Type
3
+
4
+ from algomancy_gui.appconfiguration import AppConfiguration
5
+ from algomancy_utils.logger import Logger, MessageStatus
6
+ from algomancy_data import ETLFactory, InputFileConfiguration, BASE_DATA_BOUND
7
+ from algomancy_scenario import (
8
+ ScenarioManager,
9
+ BaseKPI,
10
+ BaseAlgorithm,
11
+ BaseParameterSet,
12
+ )
13
+
14
+
15
+ class SessionManager:
16
+ """
17
+ Container for all the scenario managers.
18
+ Can create a default scenario manager when a new session is created.
19
+ """
20
+
21
+ E = TypeVar("E", bound=ETLFactory)
22
+
23
+ @classmethod
24
+ def from_config(cls, configuration: "AppConfiguration") -> "SessionManager":
25
+ # Local import to avoid heavy top-level coupling
26
+ from algomancy_gui.appconfiguration import AppConfiguration # type: ignore
27
+
28
+ if not isinstance(configuration, AppConfiguration):
29
+ raise TypeError("from_config expects an AppConfiguration instance")
30
+ return cls(
31
+ etl_factory=configuration.etl_factory,
32
+ kpi_templates=configuration.kpi_templates,
33
+ algo_templates=configuration.algo_templates,
34
+ input_configs=configuration.input_configs,
35
+ data_object_type=configuration.data_object_type,
36
+ data_folder=configuration.data_path,
37
+ has_persistent_state=configuration.has_persistent_state,
38
+ save_type=configuration.save_type,
39
+ auto_create=configuration.autocreate,
40
+ default_algo_name=configuration.default_algo,
41
+ default_param_values=configuration.default_algo_params_values,
42
+ autorun=configuration.autorun,
43
+ )
44
+
45
+ def __init__(
46
+ self,
47
+ etl_factory: type[E],
48
+ kpi_templates: Dict[str, Type[BaseKPI]],
49
+ algo_templates: Dict[str, Type[BaseAlgorithm]],
50
+ input_configs: List[InputFileConfiguration],
51
+ data_object_type: type[BASE_DATA_BOUND], # for extensions of datasource
52
+ data_folder: str = None,
53
+ logger: Logger = None,
54
+ scenario_save_location: str = "scenarios.json",
55
+ has_persistent_state: bool = False,
56
+ save_type: str = "json", # adjusts the format
57
+ auto_create: bool = False,
58
+ default_algo_name: str = None,
59
+ default_param_values: Dict[str, any] = None,
60
+ autorun: bool = False,
61
+ ) -> None:
62
+ # Store general information
63
+ self.logger = logger if logger else Logger()
64
+ self._etl_factory = etl_factory
65
+ self._kpi_templates = kpi_templates
66
+ self._algo_templates = algo_templates
67
+ self._input_configs = input_configs
68
+ self._data_object_type = data_object_type
69
+ self._autorun = autorun
70
+ self._scenario_save_location = scenario_save_location
71
+ self._data_folder = data_folder
72
+ self._has_persistent_state = has_persistent_state
73
+ self._auto_create_scenario = auto_create
74
+ self._default_algo_name = default_algo_name
75
+ self._default_param_values = default_param_values
76
+ self._algo_templates = algo_templates
77
+
78
+ assert save_type in ["json"], "Save type must be parquet or json."
79
+ self._save_type = save_type
80
+
81
+ # Create sessions
82
+ self._sessions = {}
83
+ self._create_default_scenario_managers()
84
+ self._start_session_name = list(self._sessions.keys())[0]
85
+
86
+ self.log("SessionManager initialized.")
87
+
88
+ def _create_default_scenario_managers(self) -> None:
89
+ if self._has_persistent_state:
90
+ assert self._data_folder, (
91
+ "Data folder must be specified if a persistent state is used."
92
+ )
93
+
94
+ sessions = self._determine_sessions_from_folder(self._data_folder)
95
+ for session_name, session_path in sessions.items():
96
+ self._create_default_scenario_manager(session_name, session_path)
97
+ if len(self._sessions) == 0:
98
+ self._create_default_scenario_manager("main")
99
+
100
+ def log(self, message: str, status: MessageStatus = MessageStatus.INFO) -> None:
101
+ if self.logger:
102
+ self.logger.log(message, status)
103
+
104
+ @staticmethod
105
+ def _determine_sessions_from_folder(data_folder) -> Dict[str, str]:
106
+ session_folders = {
107
+ f.name: f.path for f in os.scandir(data_folder) if f.is_dir()
108
+ }
109
+ return session_folders
110
+
111
+ def get_scenario_manager(self, session_id: str) -> ScenarioManager:
112
+ if session_id not in self._sessions:
113
+ self.log(f"Session '{session_id}' not found.")
114
+ assert session_id in self._sessions, f"Scenario '{session_id}' not found."
115
+ return self._sessions[session_id]
116
+
117
+ def _create_folder(self, name: str) -> str:
118
+ session_folder = self._data_folder + "/" + name
119
+ os.makedirs(session_folder, exist_ok=True)
120
+ return session_folder
121
+
122
+ def _create_default_scenario_manager(
123
+ self, name: str, session_path: str = None
124
+ ) -> None:
125
+ if not self._has_persistent_state:
126
+ session_path = None
127
+ elif self._has_persistent_state and session_path is None:
128
+ session_path = self._create_folder(name)
129
+
130
+ self._sessions[name] = ScenarioManager(
131
+ etl_factory=self._etl_factory,
132
+ kpi_templates=self._kpi_templates,
133
+ algo_templates=self._algo_templates,
134
+ input_configs=self._input_configs,
135
+ data_object_type=self._data_object_type,
136
+ data_folder=session_path,
137
+ logger=self.logger,
138
+ has_persistent_state=self._has_persistent_state,
139
+ save_type=self._save_type,
140
+ autocreate=self._auto_create_scenario,
141
+ default_algo_name=self._default_algo_name,
142
+ default_param_values=self._default_param_values,
143
+ autorun=self._autorun,
144
+ )
145
+
146
+ @property
147
+ def sessions_names(self) -> List[str]:
148
+ return list(self._sessions.keys())
149
+
150
+ @property
151
+ def start_session_name(self) -> str:
152
+ return self._start_session_name
153
+
154
+ def get_algorithm_parameters(self, key) -> BaseParameterSet:
155
+ template: Type[BaseAlgorithm] = self._algo_templates.get(key)
156
+ if template is None:
157
+ raise KeyError(f"Unable to find template {key} in the available templates.")
158
+ return template.initialize_parameters()
159
+
160
+ def create_new_session(self, session_name: str) -> None:
161
+ self._create_default_scenario_manager(session_name)
162
+
163
+ def copy_session(self, session_name: str, new_session_name: str):
164
+ self._create_default_scenario_manager(new_session_name)
165
+
166
+ for data_key in self.get_scenario_manager(session_name).get_data_keys():
167
+ data = self.get_scenario_manager(session_name).get_data(data_key)
168
+ self.get_scenario_manager(new_session_name).set_data(data_key, data)
@@ -0,0 +1,43 @@
1
+ from typing import Dict, List
2
+
3
+
4
+ class SettingsManager:
5
+ def __init__(self, configurations: Dict):
6
+ if isinstance(configurations, dict):
7
+ self._configurations = configurations
8
+ else:
9
+ raise TypeError("SettingsManager expects a dict of settings")
10
+
11
+ def __getitem__(self, item):
12
+ return self._configurations.get(item, [])
13
+
14
+ # ===================================
15
+ # Properties for convenient access
16
+ # ===================================
17
+ @property
18
+ def compare_default_open(self) -> List[str]:
19
+ return self["compare_default_open"]
20
+
21
+ @property
22
+ def compare_ordered_list_components(self) -> List[str]:
23
+ return self["compare_ordered_list_components"]
24
+
25
+ @property
26
+ def use_cqm_loader(self) -> bool:
27
+ return self["use_cqm_loader"]
28
+
29
+ @property
30
+ def show_loading_on_datapage(self):
31
+ return self["show_loading_on_datapage"]
32
+
33
+ @property
34
+ def show_loading_on_scenariopage(self):
35
+ return self["show_loading_on_scenariopage"]
36
+
37
+ @property
38
+ def show_loading_on_comparepage(self):
39
+ return self["show_loading_on_comparepage"]
40
+
41
+ @property
42
+ def allow_param_upload_by_file(self):
43
+ return self["allow_param_upload_by_file"]