Coverage for src\cognitivefactory\interactive_clustering_gui\models\states.py: 100.00%
44 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-22 23:23 +0100
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-22 23:23 +0100
1# -*- coding: utf-8 -*-
3"""
4* Name: cognitivefactory.interactive_clustering_gui.models.states
5* Description: Definition of states models required for application runs.
6* Author: Erwan Schild
7* Created: 25/04/2022
8* Licence: CeCILL-C License v1.0 (https://cecill.info/licences.fr.html)
9"""
11# ==============================================================================
12# IMPORT PYTHON DEPENDENCIES
13# ==============================================================================
15import enum
16from typing import Any, Dict
18# ==============================================================================
19# ENUMERATION OF IC GUI STATES
20# ==============================================================================
23class ICGUIStates(str, enum.Enum): # noqa: WPS600 (subclassing str)
24 """The enumeration of available States for Interactive Clustering GUI."""
26 ###
27 ### Case of project initialization.
28 ###
30 INITIALIZATION_WITHOUT_MODELIZATION: str = "INITIALIZATION_WITHOUT_MODELIZATION"
31 INITIALIZATION_WITH_PENDING_MODELIZATION: str = "INITIALIZATION_WITH_PENDING_MODELIZATION"
32 INITIALIZATION_WITH_WORKING_MODELIZATION: str = "INITIALIZATION_WITH_WORKING_MODELIZATION"
33 INITIALIZATION_WITH_ERRORS: str = "INITIALIZATION_WITH_ERRORS"
35 ###
36 ### Case of constraints sampling.
37 ###
39 # Sampling tasks.
40 SAMPLING_TODO: str = "SAMPLING_TODO"
41 SAMPLING_PENDING: str = "SAMPLING_PENDING"
42 SAMPLING_WORKING: str = "SAMPLING_WORKING"
43 # Import on sampling step.
44 IMPORT_AT_SAMPLING_STEP_WITHOUT_MODELIZATION: str = "IMPORT_AT_SAMPLING_STEP_WITHOUT_MODELIZATION"
45 IMPORT_AT_SAMPLING_STEP_WITH_PENDING_MODELIZATION: str = "IMPORT_AT_SAMPLING_STEP_WITH_PENDING_MODELIZATION"
46 IMPORT_AT_SAMPLING_STEP_WITH_WORKING_MODELIZATION: str = "IMPORT_AT_SAMPLING_STEP_WITH_WORKING_MODELIZATION"
47 IMPORT_AT_SAMPLING_STEP_WITH_ERRORS: str = "IMPORT_AT_SAMPLING_STEP_WITH_ERRORS"
49 ###
50 ### Case of constraints annotation.
51 ###
53 # Modelization up to date.
54 ANNOTATION_WITH_UPTODATE_MODELIZATION: str = "ANNOTATION_WITH_UPTODATE_MODELIZATION"
55 # Modelization outdated, without conflicts.
56 ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS: str = (
57 "ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS"
58 )
59 ANNOTATION_WITH_PENDING_MODELIZATION_WITHOUT_CONFLICTS: str = (
60 "ANNOTATION_WITH_PENDING_MODELIZATION_WITHOUT_CONFLICTS"
61 )
62 ANNOTATION_WITH_WORKING_MODELIZATION_WITHOUT_CONFLICTS: str = (
63 "ANNOTATION_WITH_WORKING_MODELIZATION_WITHOUT_CONFLICTS"
64 )
65 # Modelization outdated, with conflicts.
66 ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS: str = "ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS"
67 ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS: str = "ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS"
68 ANNOTATION_WITH_WORKING_MODELIZATION_WITH_CONFLICTS: str = "ANNOTATION_WITH_WORKING_MODELIZATION_WITH_CONFLICTS"
69 # Import on annotation step.
70 IMPORT_AT_ANNOTATION_STEP_WITHOUT_MODELIZATION: str = "IMPORT_AT_ANNOTATION_STEP_WITHOUT_MODELIZATION"
71 IMPORT_AT_ANNOTATION_STEP_WITH_PENDING_MODELIZATION: str = "IMPORT_AT_ANNOTATION_STEP_WITH_PENDING_MODELIZATION"
72 IMPORT_AT_ANNOTATION_STEP_WITH_WORKING_MODELIZATION: str = "IMPORT_AT_ANNOTATION_STEP_WITH_WORKING_MODELIZATION"
73 IMPORT_AT_ANNOTATION_STEP_WITH_ERRORS: str = "IMPORT_AT_ANNOTATION_STEP_WITH_ERRORS"
75 ###
76 ### Case of constrained clustering.
77 ###
79 # Clustering tasks.
80 CLUSTERING_TODO: str = "CLUSTERING_TODO"
81 CLUSTERING_PENDING: str = "CLUSTERING_PENDING"
82 CLUSTERING_WORKING: str = "CLUSTERING_WORKING"
83 # Import on clustering step.
84 IMPORT_AT_CLUSTERING_STEP_WITHOUT_MODELIZATION: str = "IMPORT_AT_CLUSTERING_STEP_WITHOUT_MODELIZATION"
85 IMPORT_AT_CLUSTERING_STEP_WITH_PENDING_MODELIZATION: str = "IMPORT_AT_CLUSTERING_STEP_WITH_PENDING_MODELIZATION"
86 IMPORT_AT_CLUSTERING_STEP_WITH_WORKING_MODELIZATION: str = "IMPORT_AT_CLUSTERING_STEP_WITH_WORKING_MODELIZATION"
87 IMPORT_AT_CLUSTERING_STEP_WITH_ERRORS: str = "IMPORT_AT_CLUSTERING_STEP_WITH_ERRORS"
89 ###
90 ### Case of iteration end.
91 ###
93 # End of iteration.
94 ITERATION_END: str = "ITERATION_END"
95 # Import on iteration end.
96 IMPORT_AT_ITERATION_END_WITHOUT_MODELIZATION: str = "IMPORT_AT_ITERATION_END_WITHOUT_MODELIZATION"
97 IMPORT_AT_ITERATION_END_WITH_PENDING_MODELIZATION: str = "IMPORT_AT_ITERATION_END_WITH_PENDING_MODELIZATION"
98 IMPORT_AT_ITERATION_END_WITH_WORKING_MODELIZATION: str = "IMPORT_AT_ITERATION_END_WITH_WORKING_MODELIZATION"
99 IMPORT_AT_ITERATION_END_WITH_ERRORS: str = "IMPORT_AT_ITERATION_END_WITH_ERRORS"
101 @classmethod
102 def contains(cls, state: str) -> bool:
103 """Test if state is in this enumeration.
105 Args:
106 state (str): A state.
108 Returns:
109 bool: `True` if the state is in the enumeration.
110 """
111 return state in cls._value2member_map_
114# ==============================================================================
115# SET ICGUI STATES DETAILS
116# ==============================================================================
119def get_ICGUIStates_details(
120 state: ICGUIStates,
121) -> Dict[str, Any]:
122 """
123 Get state details.
125 Args:
126 state (ICGUIStates): The state.
128 Returns:
129 Dict[str, Any]: The state details.
130 """
132 map_of_ICGUIStates_details: Dict[ICGUIStates, Dict[str, Any]] = {
133 ICGUIStates.INITIALIZATION_WITHOUT_MODELIZATION: {
134 "step": "CLUSTERING",
135 "step_status": "LOCKED",
136 "modelization_status": "TODO",
137 "conflict_status": "UNKNOWN",
138 },
139 ICGUIStates.INITIALIZATION_WITH_PENDING_MODELIZATION: {
140 "step": "CLUSTERING",
141 "step_status": "LOCKED",
142 "modelization_status": "PENDING",
143 "conflict_status": "UNKNOWN",
144 },
145 ICGUIStates.INITIALIZATION_WITH_WORKING_MODELIZATION: {
146 "step": "CLUSTERING",
147 "step_status": "LOCKED",
148 "modelization_status": "WORKING",
149 "conflict_status": "UNKNOWN",
150 },
151 ICGUIStates.INITIALIZATION_WITH_ERRORS: {
152 "step": "CLUSTERING",
153 "step_status": "LOCKED",
154 "modelization_status": "ERROR",
155 "conflict_status": "UNKNOWN",
156 },
157 ###
158 ### Case of constraints sampling.
159 ###
160 # Sampling tasks.
161 ICGUIStates.SAMPLING_TODO: {
162 "step": "SAMPLING",
163 "step_status": "TODO",
164 "modelization_status": "UPTODATE",
165 "conflict_status": "FALSE",
166 },
167 ICGUIStates.SAMPLING_PENDING: {
168 "step": "SAMPLING",
169 "step_status": "PENDING",
170 "modelization_status": "UPTODATE",
171 "conflict_status": "FALSE",
172 },
173 ICGUIStates.SAMPLING_WORKING: {
174 "step": "SAMPLING",
175 "step_status": "WORKING",
176 "modelization_status": "UPTODATE",
177 "conflict_status": "FALSE",
178 },
179 # Import on sampling step.
180 ICGUIStates.IMPORT_AT_SAMPLING_STEP_WITHOUT_MODELIZATION: {
181 "step": "SAMPLING",
182 "step_status": "LOCKED",
183 "modelization_status": "TODO",
184 "conflict_status": "UNKNOWN",
185 },
186 ICGUIStates.IMPORT_AT_SAMPLING_STEP_WITH_PENDING_MODELIZATION: {
187 "step": "SAMPLING",
188 "step_status": "LOCKED",
189 "modelization_status": "PENDING",
190 "conflict_status": "UNKNOWN",
191 },
192 ICGUIStates.IMPORT_AT_SAMPLING_STEP_WITH_WORKING_MODELIZATION: {
193 "step": "SAMPLING",
194 "step_status": "LOCKED",
195 "modelization_status": "WORKING",
196 "conflict_status": "UNKNOWN",
197 },
198 ICGUIStates.IMPORT_AT_SAMPLING_STEP_WITH_ERRORS: {
199 "step": "SAMPLING",
200 "step_status": "LOCKED",
201 "modelization_status": "ERROR",
202 "conflict_status": "UNKNOWN",
203 },
204 ###
205 ### Case of constraints annotation.
206 ###
207 # Modelization up to date.
208 ICGUIStates.ANNOTATION_WITH_UPTODATE_MODELIZATION: {
209 "step": "ANNOTATION",
210 "step_status": "TODO",
211 "modelization_status": "UPTODATE",
212 "conflict_status": "FALSE",
213 },
214 # Modelization outdated, without conflicts.
215 ICGUIStates.ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS: {
216 "step": "ANNOTATION",
217 "step_status": "TODO",
218 "modelization_status": "OUTDATED",
219 "conflict_status": "FALSE",
220 },
221 ICGUIStates.ANNOTATION_WITH_PENDING_MODELIZATION_WITHOUT_CONFLICTS: {
222 "step": "ANNOTATION",
223 "step_status": "LOCKED",
224 "modelization_status": "PENDING",
225 "conflict_status": "FALSE",
226 },
227 ICGUIStates.ANNOTATION_WITH_WORKING_MODELIZATION_WITHOUT_CONFLICTS: {
228 "step": "ANNOTATION",
229 "step_status": "LOCKED",
230 "modelization_status": "WORKING",
231 "conflict_status": "FALSE",
232 },
233 # Modelization outdated, with conflicts.
234 ICGUIStates.ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS: {
235 "step": "ANNOTATION",
236 "step_status": "TODO",
237 "modelization_status": "OUTDATED",
238 "conflict_status": "TRUE",
239 },
240 ICGUIStates.ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS: {
241 "step": "ANNOTATION",
242 "step_status": "LOCKED",
243 "modelization_status": "PENDING",
244 "conflict_status": "TRUE",
245 },
246 ICGUIStates.ANNOTATION_WITH_WORKING_MODELIZATION_WITH_CONFLICTS: {
247 "step": "ANNOTATION",
248 "step_status": "LOCKED",
249 "modelization_status": "WORKING",
250 "conflict_status": "TRUE",
251 },
252 # Import on annotation step.
253 ICGUIStates.IMPORT_AT_ANNOTATION_STEP_WITHOUT_MODELIZATION: {
254 "step": "ANNOTATION",
255 "step_status": "LOCKED",
256 "modelization_status": "TODO",
257 "conflict_status": "UNKNOWN",
258 },
259 ICGUIStates.IMPORT_AT_ANNOTATION_STEP_WITH_PENDING_MODELIZATION: {
260 "step": "ANNOTATION",
261 "step_status": "LOCKED",
262 "modelization_status": "PENDING",
263 "conflict_status": "UNKNOWN",
264 },
265 ICGUIStates.IMPORT_AT_ANNOTATION_STEP_WITH_WORKING_MODELIZATION: {
266 "step": "ANNOTATION",
267 "step_status": "LOCKED",
268 "modelization_status": "WORKING",
269 "conflict_status": "UNKNOWN",
270 },
271 ICGUIStates.IMPORT_AT_ANNOTATION_STEP_WITH_ERRORS: {
272 "step": "ANNOTATION",
273 "step_status": "LOCKED",
274 "modelization_status": "ERROR",
275 "conflict_status": "UNKNOWN",
276 },
277 ###
278 ### Case of constrained clustering.
279 ###
280 # Clustering tasks.
281 ICGUIStates.CLUSTERING_TODO: {
282 "step": "CLUSTERING",
283 "step_status": "TODO",
284 "modelization_status": "UPTODATE",
285 "conflict_status": "FALSE",
286 },
287 ICGUIStates.CLUSTERING_PENDING: {
288 "step": "CLUSTERING",
289 "step_status": "PENDING",
290 "modelization_status": "UPTODATE",
291 "conflict_status": "FALSE",
292 },
293 ICGUIStates.CLUSTERING_WORKING: {
294 "step": "CLUSTERING",
295 "step_status": "WORKING",
296 "modelization_status": "UPTODATE",
297 "conflict_status": "FALSE",
298 },
299 # Import on clustering step.
300 ICGUIStates.IMPORT_AT_CLUSTERING_STEP_WITHOUT_MODELIZATION: {
301 "step": "CLUSTERING",
302 "step_status": "LOCKED",
303 "modelization_status": "TODO",
304 "conflict_status": "UNKNOWN",
305 },
306 ICGUIStates.IMPORT_AT_CLUSTERING_STEP_WITH_PENDING_MODELIZATION: {
307 "step": "CLUSTERING",
308 "step_status": "LOCKED",
309 "modelization_status": "PENDING",
310 "conflict_status": "UNKNOWN",
311 },
312 ICGUIStates.IMPORT_AT_CLUSTERING_STEP_WITH_WORKING_MODELIZATION: {
313 "step": "CLUSTERING",
314 "step_status": "LOCKED",
315 "modelization_status": "WORKING",
316 "conflict_status": "UNKNOWN",
317 },
318 ICGUIStates.IMPORT_AT_CLUSTERING_STEP_WITH_ERRORS: {
319 "step": "CLUSTERING",
320 "step_status": "LOCKED",
321 "modelization_status": "ERROR",
322 "conflict_status": "UNKNOWN",
323 },
324 ###
325 ### Case of iteration end.
326 ###
327 # End of iteration.
328 ICGUIStates.ITERATION_END: {
329 "step": "ITERATION_END",
330 "step_status": "TODO",
331 "modelization_status": "UPTODATE",
332 "conflict_status": "FALSE",
333 },
334 # Import on iteration end.
335 ICGUIStates.IMPORT_AT_ITERATION_END_WITHOUT_MODELIZATION: {
336 "step": "ITERATION_END",
337 "step_status": "LOCKED",
338 "modelization_status": "TODO",
339 "conflict_status": "UNKNOWN",
340 },
341 ICGUIStates.IMPORT_AT_ITERATION_END_WITH_PENDING_MODELIZATION: {
342 "step": "ITERATION_END",
343 "step_status": "LOCKED",
344 "modelization_status": "PENDING",
345 "conflict_status": "UNKNOWN",
346 },
347 ICGUIStates.IMPORT_AT_ITERATION_END_WITH_WORKING_MODELIZATION: {
348 "step": "ITERATION_END",
349 "step_status": "LOCKED",
350 "modelization_status": "WORKING",
351 "conflict_status": "UNKNOWN",
352 },
353 ICGUIStates.IMPORT_AT_ITERATION_END_WITH_ERRORS: {
354 "step": "ITERATION_END",
355 "step_status": "LOCKED",
356 "modelization_status": "ERROR",
357 "conflict_status": "UNKNOWN",
358 },
359 }
361 return map_of_ICGUIStates_details[state]