robert 2.2.0__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 (261) hide show
  1. robert/__init__.py +9 -0
  2. robert/__main__.py +20 -0
  3. robert/_version.py +3 -0
  4. robert/api.py +646 -0
  5. robert/aqme.py +280 -0
  6. robert/argument_parser.py +98 -0
  7. robert/checkml.py +433 -0
  8. robert/checkml_score.py +50 -0
  9. robert/curate.py +217 -0
  10. robert/evaluate_bot_retrieval.py +125 -0
  11. robert/evaluate_bot_support.py +102 -0
  12. robert/evaluate_workflow_summaries.py +87 -0
  13. robert/export_bot_docs_knowledge.py +1632 -0
  14. robert/generate.py +249 -0
  15. robert/generate_utils.py +311 -0
  16. robert/gui_easyrob/__init__.py +0 -0
  17. robert/gui_easyrob/assets/gif_easyrob.gif +0 -0
  18. robert/gui_easyrob/bot/__init__.py +47 -0
  19. robert/gui_easyrob/bot/answer_metadata.py +198 -0
  20. robert/gui_easyrob/bot/bot_context.py +679 -0
  21. robert/gui_easyrob/bot/bot_engine.py +1100 -0
  22. robert/gui_easyrob/bot/bot_panel.py +1231 -0
  23. robert/gui_easyrob/bot/bot_rag.py +1178 -0
  24. robert/gui_easyrob/bot/bot_window.py +39 -0
  25. robert/gui_easyrob/bot/bot_worker.py +149 -0
  26. robert/gui_easyrob/bot/credential_store.py +143 -0
  27. robert/gui_easyrob/bot/error_parser.py +105 -0
  28. robert/gui_easyrob/bot/evidence_policy.py +164 -0
  29. robert/gui_easyrob/bot/heuristics.py +859 -0
  30. robert/gui_easyrob/bot/icons.py +56 -0
  31. robert/gui_easyrob/bot/input_csv_audit.py +212 -0
  32. robert/gui_easyrob/bot/knowledge/aqme_context.json +5907 -0
  33. robert/gui_easyrob/bot/knowledge/robert_context.json +4817 -0
  34. robert/gui_easyrob/bot/knowledge/ui_context.json +8293 -0
  35. robert/gui_easyrob/bot/knowledge_schema.py +1252 -0
  36. robert/gui_easyrob/bot/knowledge_sources/aqme_user_guidance.json +442 -0
  37. robert/gui_easyrob/bot/knowledge_sources/coverage_manifest.json +95 -0
  38. robert/gui_easyrob/bot/knowledge_sources/robert_user_guidance.json +471 -0
  39. robert/gui_easyrob/bot/knowledge_sources/ui_user_guidance.json +1312 -0
  40. robert/gui_easyrob/bot/llm_providers.py +1573 -0
  41. robert/gui_easyrob/bot/online_docs.py +105 -0
  42. robert/gui_easyrob/bot/prompt_policy.py +575 -0
  43. robert/gui_easyrob/bot/question_intent.py +562 -0
  44. robert/gui_easyrob/bot/response_quality.py +104 -0
  45. robert/gui_easyrob/bot/result_insights.py +225 -0
  46. robert/gui_easyrob/bot/token_usage.py +75 -0
  47. robert/gui_easyrob/bot/workflow_results.py +1396 -0
  48. robert/gui_easyrob/checkml_launcher.py +15 -0
  49. robert/gui_easyrob/easyrob.py +29 -0
  50. robert/gui_easyrob/easyrob_launcher.py +113 -0
  51. robert/gui_easyrob/main/__init__.py +9 -0
  52. robert/gui_easyrob/main/window.py +5152 -0
  53. robert/gui_easyrob/result_navigation.py +14 -0
  54. robert/gui_easyrob/tabs/__init__.py +23 -0
  55. robert/gui_easyrob/tabs/advanced_options.py +370 -0
  56. robert/gui_easyrob/tabs/aqme.py +1234 -0
  57. robert/gui_easyrob/tabs/checkml.py +898 -0
  58. robert/gui_easyrob/tabs/images.py +427 -0
  59. robert/gui_easyrob/tabs/interactive_predictions.py +555 -0
  60. robert/gui_easyrob/tabs/molssi.py +447 -0
  61. robert/gui_easyrob/tabs/predictions.py +484 -0
  62. robert/gui_easyrob/tabs/result_catalog.py +170 -0
  63. robert/gui_easyrob/tabs/results.py +490 -0
  64. robert/gui_easyrob/tabs/results_workspace.py +120 -0
  65. robert/gui_easyrob/test_bot_input_csv_audit.py +152 -0
  66. robert/gui_easyrob/test_bot_question_routing.py +383 -0
  67. robert/gui_easyrob/test_bot_result_analysis.py +356 -0
  68. robert/gui_easyrob/test_bot_retrieval_evaluation.py +110 -0
  69. robert/gui_easyrob/test_bot_ui_integration.py +278 -0
  70. robert/gui_easyrob/test_checkml_app_mode.py +124 -0
  71. robert/gui_easyrob/test_checkml_completion.py +57 -0
  72. robert/gui_easyrob/test_checkml_defaults.py +37 -0
  73. robert/gui_easyrob/test_checkml_result_summary.py +113 -0
  74. robert/gui_easyrob/test_checkml_web_mode.py +57 -0
  75. robert/gui_easyrob/test_dialog_layout.py +33 -0
  76. robert/gui_easyrob/test_gui_bot_regressions.py +320 -0
  77. robert/gui_easyrob/test_molssi_auto.py +569 -0
  78. robert/gui_easyrob/test_tutorial_view.py +215 -0
  79. robert/gui_easyrob/tutorials/check_model.md +25 -0
  80. robert/gui_easyrob/tutorials/chemdraw.md +49 -0
  81. robert/gui_easyrob/tutorials/csv.md +53 -0
  82. robert/gui_easyrob/tutorials/descriptors.md +21 -0
  83. robert/gui_easyrob/tutorials/overview.md +65 -0
  84. robert/gui_easyrob/tutorials/predictions.md +25 -0
  85. robert/gui_easyrob/tutorials/robbot.md +29 -0
  86. robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_1.png +0 -0
  87. robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_2.png +0 -0
  88. robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_3.png +0 -0
  89. robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_4.png +0 -0
  90. robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_5.png +0 -0
  91. robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_6.png +0 -0
  92. robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_7.png +0 -0
  93. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_1.png +0 -0
  94. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_10.png +0 -0
  95. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_11.png +0 -0
  96. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_12.png +0 -0
  97. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_13.png +0 -0
  98. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_2.png +0 -0
  99. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_3.png +0 -0
  100. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_4.png +0 -0
  101. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_5.png +0 -0
  102. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_6.png +0 -0
  103. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_7.png +0 -0
  104. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_8.png +0 -0
  105. robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_9.png +0 -0
  106. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1.png +0 -0
  107. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_1.png +0 -0
  108. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_2.png +0 -0
  109. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_3.png +0 -0
  110. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_4.png +0 -0
  111. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_5.png +0 -0
  112. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_2.png +0 -0
  113. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_3.png +0 -0
  114. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_4.png +0 -0
  115. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_5.png +0 -0
  116. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_6.png +0 -0
  117. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_7.png +0 -0
  118. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_8.png +0 -0
  119. robert/gui_easyrob/tutorials/tutorial_images/csv/csv_9.png +0 -0
  120. robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_1.png +0 -0
  121. robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_2.png +0 -0
  122. robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_3.png +0 -0
  123. robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_4.png +0 -0
  124. robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_5.png +0 -0
  125. robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_6.png +0 -0
  126. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1.png +0 -0
  127. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_1.png +0 -0
  128. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_2.png +0 -0
  129. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_3.png +0 -0
  130. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_4.png +0 -0
  131. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_5.png +0 -0
  132. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_6.png +0 -0
  133. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_7.png +0 -0
  134. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_8.png +0 -0
  135. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_2.png +0 -0
  136. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_3.png +0 -0
  137. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_4.png +0 -0
  138. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5.png +0 -0
  139. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_1.png +0 -0
  140. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_2.png +0 -0
  141. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_3.png +0 -0
  142. robert/gui_easyrob/tutorials/tutorial_images/overview/overview_6.png +0 -0
  143. robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_1.png +0 -0
  144. robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_1_1.png +0 -0
  145. robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_2.png +0 -0
  146. robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_3.png +0 -0
  147. robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_4.png +0 -0
  148. robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_5.png +0 -0
  149. robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_6.png +0 -0
  150. robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_1.png +0 -0
  151. robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_2.png +0 -0
  152. robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_3.png +0 -0
  153. robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_4.png +0 -0
  154. robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_5.png +0 -0
  155. robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_6.png +0 -0
  156. robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_7.png +0 -0
  157. robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_8.png +0 -0
  158. robert/gui_easyrob/utils/__init__.py +0 -0
  159. robert/gui_easyrob/utils/aqme_utils.py +238 -0
  160. robert/gui_easyrob/utils/molssi_utils.py +584 -0
  161. robert/gui_easyrob/utils/predictions_utils.py +985 -0
  162. robert/gui_easyrob/utils/utils_gui.py +738 -0
  163. robert/gui_easyrob/version.py +68 -0
  164. robert/gui_easyrob/web/app.css +484 -0
  165. robert/gui_easyrob/web/app.html +134 -0
  166. robert/gui_easyrob/web/app.js +764 -0
  167. robert/gui_easyrob/web/checkml_brand.png +0 -0
  168. robert/gui_easyrob/web/easyrob_background.gif +0 -0
  169. robert/gui_easyrob/web/easyrob_background.png +0 -0
  170. robert/gui_easyrob/web/images.css +89 -0
  171. robert/gui_easyrob/web/images.html +39 -0
  172. robert/gui_easyrob/web/images.js +101 -0
  173. robert/gui_easyrob/web/results.js +499 -0
  174. robert/gui_easyrob/web/robert_brand.png +0 -0
  175. robert/gui_easyrob/web_dialogs.py +64 -0
  176. robert/gui_easyrob/web_results.py +253 -0
  177. robert/gui_easyrob/web_shell.py +684 -0
  178. robert/gui_easyrob/workflow_progress.py +89 -0
  179. robert/gui_easyrob/workflow_run_lock.py +27 -0
  180. robert/icons/CheckML_icon.png +0 -0
  181. robert/icons/Robert_icon.png +0 -0
  182. robert/icons/Robert_logo.jpg +0 -0
  183. robert/icons/Robert_logo_transparent.png +0 -0
  184. robert/icons/documentation_icon.png +0 -0
  185. robert/icons/info_icon.png +0 -0
  186. robert/icons/pdf_icon.png +0 -0
  187. robert/icons/play_icon.png +0 -0
  188. robert/icons/stop_icon.png +0 -0
  189. robert/icons/youtube_icon.ico +0 -0
  190. robert/predict.py +193 -0
  191. robert/predict_utils.py +410 -0
  192. robert/report/CheckML_logo.jpg +0 -0
  193. robert/report/GENERATE.png +0 -0
  194. robert/report/Robert_icon.ico +0 -0
  195. robert/report/Robert_logo.jpg +0 -0
  196. robert/report/Robert_logo1.jpg +0 -0
  197. robert/report/abbrev.png +0 -0
  198. robert/report/adv_anal.png +0 -0
  199. robert/report/checkml_pass.svg +3 -0
  200. robert/report/checkml_unclear.svg +3 -0
  201. robert/report/checkml_warning.svg +3 -0
  202. robert/report/features.png +0 -0
  203. robert/report/outliers.png +0 -0
  204. robert/report/pred.png +0 -0
  205. robert/report/repro.png +0 -0
  206. robert/report/robust_x.png +0 -0
  207. robert/report/robust_y_high.png +0 -0
  208. robert/report/robust_y_low.png +0 -0
  209. robert/report/score.png +0 -0
  210. robert/report/score_0.jpg +0 -0
  211. robert/report/score_1.jpg +0 -0
  212. robert/report/score_10.jpg +0 -0
  213. robert/report/score_2.jpg +0 -0
  214. robert/report/score_3.jpg +0 -0
  215. robert/report/score_4.jpg +0 -0
  216. robert/report/score_5.jpg +0 -0
  217. robert/report/score_6.jpg +0 -0
  218. robert/report/score_7.jpg +0 -0
  219. robert/report/score_8.jpg +0 -0
  220. robert/report/score_9.jpg +0 -0
  221. robert/report/score_gray_0.jpg +0 -0
  222. robert/report/score_gray_1.jpg +0 -0
  223. robert/report/score_gray_10.jpg +0 -0
  224. robert/report/score_gray_2.jpg +0 -0
  225. robert/report/score_gray_3.jpg +0 -0
  226. robert/report/score_gray_4.jpg +0 -0
  227. robert/report/score_gray_5.jpg +0 -0
  228. robert/report/score_gray_6.jpg +0 -0
  229. robert/report/score_gray_7.jpg +0 -0
  230. robert/report/score_gray_8.jpg +0 -0
  231. robert/report/score_gray_9.jpg +0 -0
  232. robert/report/score_w_1_0.jpg +0 -0
  233. robert/report/score_w_1_1.jpg +0 -0
  234. robert/report/score_w_2_0.jpg +0 -0
  235. robert/report/score_w_2_1.jpg +0 -0
  236. robert/report/score_w_2_2.jpg +0 -0
  237. robert/report/score_w_2_gray_0.jpg +0 -0
  238. robert/report/score_w_2_gray_1.jpg +0 -0
  239. robert/report/score_w_2_gray_2.jpg +0 -0
  240. robert/report/score_w_3_0.jpg +0 -0
  241. robert/report/score_w_3_1.jpg +0 -0
  242. robert/report/score_w_3_2.jpg +0 -0
  243. robert/report/score_w_3_3.jpg +0 -0
  244. robert/report/score_w_4_0.jpg +0 -0
  245. robert/report/score_w_4_1.JPG +0 -0
  246. robert/report/score_w_4_2.jpg +0 -0
  247. robert/report/score_w_4_3.jpg +0 -0
  248. robert/report/score_w_4_4.jpg +0 -0
  249. robert/report/transpa.png +0 -0
  250. robert/report/y_distrib.png +0 -0
  251. robert/report.py +2880 -0
  252. robert/report_utils.py +2270 -0
  253. robert/robert.py +181 -0
  254. robert/utils.py +4763 -0
  255. robert/verify.py +606 -0
  256. robert-2.2.0.dist-info/METADATA +55 -0
  257. robert-2.2.0.dist-info/RECORD +261 -0
  258. robert-2.2.0.dist-info/WHEEL +5 -0
  259. robert-2.2.0.dist-info/entry_points.txt +3 -0
  260. robert-2.2.0.dist-info/licenses/LICENSE +21 -0
  261. robert-2.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,679 @@
1
+ """Snapshot extraction helpers for the EasyROB GUI bot."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ import math
7
+ from pathlib import Path
8
+ import re
9
+ from typing import Any, Final
10
+
11
+ from .error_parser import parse_python_failure
12
+ from .workflow_results import WorkflowResultSnapshot
13
+
14
+ __all__ = ["POPUP_CONTEXT_TTL_SECONDS", "GuiSnapshot", "active_gui_page", "build_gui_snapshot"]
15
+
16
+
17
+ _TOKEN_RE = re.compile(r"[a-z0-9_]+")
18
+ _RECENT_CONSOLE_LIMIT = 2000
19
+ POPUP_CONTEXT_TTL_SECONDS: Final[float] = 30.0
20
+ _POPUP_TITLE_LIMIT = 240
21
+ _POPUP_TEXT_LIMIT = 4000
22
+ _POPUP_BUTTON_LIMIT = 120
23
+ _POPUP_BUTTON_COUNT_LIMIT = 12
24
+ _POPUP_TAG_LIMIT = 120
25
+ _GUI_LIST_ITEM_LIMIT = 160
26
+ _GUI_LIST_COUNT_LIMIT = 40
27
+ _CONSOLE_PHRASE_MARKERS = (
28
+ "column missing",
29
+ "target column must be numeric",
30
+ "target column is empty",
31
+ "no valid molecules",
32
+ "please select a csv file",
33
+ "expected output csv",
34
+ "could not delete folder",
35
+ )
36
+
37
+
38
+ def _maybe_call(value: Any, *args: Any) -> Any:
39
+ return value(*args) if callable(value) else value
40
+
41
+
42
+ def _safe_maybe_call(value: Any, *args: Any, default: Any = None) -> Any:
43
+ """Call one explicitly selected GUI accessor once, treating failures as absent."""
44
+ try:
45
+ return _maybe_call(value, *args)
46
+ except Exception:
47
+ return default
48
+
49
+
50
+ def _get_attr(obj: Any, name: str, default: Any = "") -> Any:
51
+ if obj is None:
52
+ return default
53
+ try:
54
+ return getattr(obj, name, default)
55
+ except Exception:
56
+ return default
57
+
58
+
59
+ def _text_from_widget(widget: Any, method_name: str, default: str = "", *args: Any) -> str:
60
+ method = _get_attr(widget, method_name, None)
61
+ if not callable(method):
62
+ return default
63
+ value = _safe_maybe_call(method, *args, default=None)
64
+ if value is None:
65
+ return default
66
+ return str(value)
67
+
68
+
69
+ def _tokenize(value: object) -> list[str]:
70
+ if value is None:
71
+ return []
72
+ if isinstance(value, (list, tuple, set)):
73
+ tokens: list[str] = []
74
+ for item in value:
75
+ tokens.extend(_tokenize(item))
76
+ return tokens
77
+ return _TOKEN_RE.findall(str(value).lower())
78
+
79
+
80
+ def _append_console_phrase_markers(console_text: str, terms: list[str]) -> list[str]:
81
+ lowered = console_text.lower()
82
+ enriched = list(terms)
83
+ for marker in _CONSOLE_PHRASE_MARKERS:
84
+ if marker in lowered and marker not in enriched:
85
+ enriched.append(marker)
86
+ if "not found" in lowered and "not found" not in enriched:
87
+ enriched.append("not found")
88
+ return enriched
89
+
90
+
91
+ def _popup_value(popup: Any, key: str, default: Any = "") -> Any:
92
+ if popup is None:
93
+ return default
94
+ if isinstance(popup, dict):
95
+ return popup.get(key, default)
96
+ return _get_attr(popup, key, default)
97
+
98
+
99
+ def _bounded_popup_text(value: Any, limit: int) -> str:
100
+ if callable(value) or value is None:
101
+ return ""
102
+ if not isinstance(value, (str, int, float, bool)):
103
+ return ""
104
+ raw_text = str(value)
105
+ safe_text = "".join(
106
+ " " if ord(character) < 32 or 127 <= ord(character) <= 159 else character
107
+ for character in raw_text
108
+ )
109
+ text = " ".join(safe_text.split())
110
+ return text[:limit]
111
+
112
+
113
+ def _popup_buttons(popup: Any) -> list[str]:
114
+ value = _popup_value(popup, "buttons", [])
115
+ if isinstance(value, str):
116
+ item = _bounded_popup_text(value, _POPUP_BUTTON_LIMIT)
117
+ return [item] if item else []
118
+ if isinstance(value, (list, tuple)):
119
+ buttons: list[str] = []
120
+ for raw_item in list(value)[:_POPUP_BUTTON_COUNT_LIMIT]:
121
+ item = _bounded_popup_text(raw_item, _POPUP_BUTTON_LIMIT)
122
+ if item:
123
+ buttons.append(item)
124
+ return buttons
125
+ return []
126
+
127
+
128
+ def _recent_console_slice(value: str, limit: int = _RECENT_CONSOLE_LIMIT) -> str:
129
+ if limit <= 0:
130
+ return ""
131
+ text = value.strip()
132
+ if len(text) <= limit:
133
+ return text
134
+ return text[-limit:]
135
+
136
+
137
+ def _normalize_int_list(value: Any) -> list[int]:
138
+ if value is None:
139
+ return []
140
+ if isinstance(value, (list, tuple, set)):
141
+ items = value
142
+ else:
143
+ items = [value]
144
+ normalized: list[int] = []
145
+ for item in items:
146
+ try:
147
+ normalized.append(int(item))
148
+ except (TypeError, ValueError):
149
+ continue
150
+ return normalized
151
+
152
+
153
+ def _normalize_text_items(value: Any) -> tuple[str, ...]:
154
+ """Return a bounded, detached tuple from GUI-owned text values."""
155
+ if not isinstance(value, (list, tuple)):
156
+ return ()
157
+ normalized: list[str] = []
158
+ for item in value[:_GUI_LIST_COUNT_LIMIT]:
159
+ text = _bounded_popup_text(item, _GUI_LIST_ITEM_LIMIT)
160
+ if text:
161
+ normalized.append(text)
162
+ return tuple(normalized)
163
+
164
+
165
+ def _collect_list_widget_text(widget: Any) -> tuple[str, ...]:
166
+ count_accessor = _get_attr(widget, "count", None)
167
+ count_value = _safe_maybe_call(count_accessor, default=0) if callable(count_accessor) else 0
168
+ try:
169
+ count = max(0, min(int(count_value or 0), _GUI_LIST_COUNT_LIMIT))
170
+ except (TypeError, ValueError):
171
+ return ()
172
+ values: list[str] = []
173
+ item_accessor = _get_attr(widget, "item", None)
174
+ if not callable(item_accessor):
175
+ return ()
176
+ for index in range(count):
177
+ item = _safe_maybe_call(item_accessor, index, default=None)
178
+ text = _bounded_popup_text(_text_from_widget(item, "text", ""), _GUI_LIST_ITEM_LIMIT)
179
+ if text:
180
+ values.append(text)
181
+ return tuple(values)
182
+
183
+
184
+ def _collect_checked_list_widget_text(widget: Any) -> tuple[str, ...]:
185
+ """Read only checked items from a checkable GUI list."""
186
+ count_accessor = _get_attr(widget, "count", None)
187
+ count_value = _safe_maybe_call(count_accessor, default=0) if callable(count_accessor) else 0
188
+ try:
189
+ count = max(0, min(int(count_value or 0), _GUI_LIST_COUNT_LIMIT))
190
+ except (TypeError, ValueError):
191
+ return ()
192
+ item_accessor = _get_attr(widget, "item", None)
193
+ if not callable(item_accessor):
194
+ return ()
195
+ values: list[str] = []
196
+ for index in range(count):
197
+ item = _safe_maybe_call(item_accessor, index, default=None)
198
+ state = _safe_maybe_call(_get_attr(item, "checkState", None), default=None)
199
+ if _get_attr(state, "value", state) != 2:
200
+ continue
201
+ text = _bounded_popup_text(_text_from_widget(item, "text", ""), _GUI_LIST_ITEM_LIMIT)
202
+ if text:
203
+ values.append(text)
204
+ return tuple(values)
205
+
206
+
207
+ def _line_edit_setting(widget: Any) -> str:
208
+ text = _text_from_widget(widget, "text", "").strip()
209
+ if text:
210
+ return text
211
+ placeholder = _text_from_widget(widget, "placeholderText", "").strip()
212
+ return f"default ({placeholder})" if placeholder else ""
213
+
214
+
215
+ def _checked(widget: Any) -> bool:
216
+ accessor = _get_attr(widget, "isChecked", None)
217
+ return bool(_safe_maybe_call(accessor, default=False)) if callable(accessor) else False
218
+
219
+
220
+ def _collect_advanced_settings(options: Any) -> tuple[str, ...]:
221
+ if options is None:
222
+ return ()
223
+ values: list[str] = []
224
+ checkbox_fields = (
225
+ ("auto_type", "auto_type"),
226
+ ("corr_filter_xbool", "corr_filter_x"),
227
+ ("corr_filter_ybool", "corr_filter_y"),
228
+ ("pfi_filter", "pfi_filter"),
229
+ ("auto_test", "auto_test"),
230
+ )
231
+ combo_fields = (
232
+ ("split", "split"),
233
+ ("categoricalstr", "categorical"),
234
+ ("error_type", "error_type"),
235
+ )
236
+ line_fields = (
237
+ ("seed", "seed"),
238
+ ("kfold", "kfold"),
239
+ ("repeat_kfolds", "repeat_kfolds"),
240
+ ("desc_thresfloat", "desc_thres"),
241
+ ("thres_xfloat", "thres_x"),
242
+ ("thres_yfloat", "thres_y"),
243
+ ("init_points", "init_points"),
244
+ ("n_iter", "n_iter"),
245
+ ("expect_improv", "expect_improv"),
246
+ ("pfi_epochs", "pfi_epochs"),
247
+ ("pfi_threshold", "pfi_threshold"),
248
+ ("pfi_max", "pfi_max"),
249
+ ("test_set", "test_set"),
250
+ ("t_value", "t_value"),
251
+ ("shap_show", "shap_show"),
252
+ ("pfi_show", "pfi_show"),
253
+ )
254
+ for attr_name, label in checkbox_fields:
255
+ widget = _get_attr(options, attr_name, None)
256
+ if widget is not None:
257
+ values.append(f"{label}={_checked(widget)}")
258
+ for attr_name, label in combo_fields:
259
+ text = _text_from_widget(_get_attr(options, attr_name, None), "currentText", "").strip()
260
+ if text:
261
+ values.append(f"{label}={text}")
262
+ for attr_name, label in line_fields:
263
+ text = _line_edit_setting(_get_attr(options, attr_name, None))
264
+ if text:
265
+ values.append(f"{label}={text}")
266
+ model_widgets = _get_attr(options, "modellist", {})
267
+ if isinstance(model_widgets, dict):
268
+ selected_models = [
269
+ str(name) for name, widget in sorted(model_widgets.items(), key=lambda item: str(item[0]))
270
+ if _checked(widget)
271
+ ]
272
+ if selected_models:
273
+ values.append(f"models={', '.join(selected_models)}")
274
+ return _normalize_text_items(values)
275
+
276
+
277
+ def _popup_age(value: Any) -> float | None:
278
+ if type(value) is int:
279
+ if value < 0 or value >= POPUP_CONTEXT_TTL_SECONDS:
280
+ return None
281
+ return float(value)
282
+ if type(value) is not float:
283
+ return None
284
+ if not math.isfinite(value) or value < 0.0 or value >= POPUP_CONTEXT_TTL_SECONDS:
285
+ return None
286
+ return value
287
+
288
+
289
+ def _is_enabled(widget: Any) -> bool:
290
+ if widget is None:
291
+ return False
292
+ if hasattr(widget, "isEnabled"):
293
+ accessor = _get_attr(widget, "isEnabled", None)
294
+ if not callable(accessor):
295
+ return False
296
+ value = _safe_maybe_call(accessor, default=False)
297
+ return bool(value)
298
+ return bool(widget)
299
+
300
+
301
+ def _is_process_running(window: Any, run_enabled: bool, stop_enabled: bool) -> bool:
302
+ if stop_enabled and not run_enabled:
303
+ return True
304
+ if run_enabled and not stop_enabled:
305
+ return False
306
+
307
+ current_process = str(_get_attr(window, "current_process", "") or "").strip()
308
+ if current_process and current_process.lower() not in {"idle", "stopped", "none"}:
309
+ return True
310
+ return False
311
+
312
+
313
+ def _collect_tab_states(tab_widget: Any) -> tuple[list[str], list[str]]:
314
+ count_method = _get_attr(tab_widget, "count", None)
315
+ count_value = _safe_maybe_call(count_method, default=0) if callable(count_method) else 0
316
+ try:
317
+ count = int(count_value or 0)
318
+ except (TypeError, ValueError):
319
+ count = 0
320
+
321
+ enabled_tabs: list[str] = []
322
+ disabled_tabs: list[str] = []
323
+ for index in range(max(count, 0)):
324
+ tab_name = _text_from_widget(tab_widget, "tabText", "", index).strip()
325
+ if not tab_name:
326
+ continue
327
+ is_enabled_method = _get_attr(tab_widget, "isTabEnabled", None)
328
+ is_enabled = bool(_safe_maybe_call(is_enabled_method, index, default=False)) if callable(is_enabled_method) else True
329
+ if is_enabled:
330
+ enabled_tabs.append(tab_name)
331
+ else:
332
+ disabled_tabs.append(tab_name)
333
+ return enabled_tabs, disabled_tabs
334
+
335
+
336
+ @dataclass(frozen=True, slots=True)
337
+ class GuiSnapshot:
338
+ active_tab: str
339
+ workflow: str
340
+ main_csv_path: str
341
+ test_csv_path: str
342
+ target_column: str
343
+ prediction_type: str
344
+ process_running: bool
345
+ run_enabled: bool
346
+ stop_enabled: bool
347
+ recent_console: str
348
+ console_terms: list[str]
349
+ name_column: str = ""
350
+ active_process: str = ""
351
+ run_aqme_enabled: bool = False
352
+ ignored_columns: tuple[str, ...] = field(default_factory=tuple)
353
+ advanced_settings: tuple[str, ...] = field(default_factory=tuple)
354
+ aqme_workflow_enabled: bool = False
355
+ enabled_tabs: list[str] = field(default_factory=list)
356
+ disabled_tabs: list[str] = field(default_factory=list)
357
+ popup_active: bool = False
358
+ popup_title: str = ""
359
+ popup_text: str = ""
360
+ popup_buttons: tuple[str, ...] = field(default_factory=tuple)
361
+ popup_kind: str = ""
362
+ popup_source: str = ""
363
+ popup_age_seconds: float | None = None
364
+ failure_type: str = ""
365
+ failure_message: str = ""
366
+ failure_location: str = ""
367
+ failure_function: str = ""
368
+ failure_operation: str = ""
369
+ likely_cause: str = ""
370
+ aqme_smarts_pattern: str = ""
371
+ aqme_message_text: str = ""
372
+ aqme_message_tooltip: str = ""
373
+ aqme_info_text: str = ""
374
+ aqme_selected_atoms: list[int] = field(default_factory=list)
375
+ aqme_descriptor_level: str = ""
376
+ aqme_solvent: str = ""
377
+ aqme_atoms_text: str = ""
378
+ aqme_multiple_matches_detected: bool = False
379
+ aqme_metal_found: bool = False
380
+ aqme_unified_smiles_count: int = 0
381
+ workflow_results: WorkflowResultSnapshot | None = None
382
+ result_model: str = ""
383
+ result_models: tuple[str, ...] = field(default_factory=tuple)
384
+ result_selected_variants: tuple[tuple[str, str], ...] = field(default_factory=tuple)
385
+ result_active_view: str = ""
386
+ result_enabled_views: tuple[str, ...] = field(default_factory=tuple)
387
+ result_disabled_views: tuple[str, ...] = field(default_factory=tuple)
388
+ all_models_enabled: bool = False
389
+ result_root_reports: tuple[str, ...] = field(default_factory=tuple)
390
+ result_archived_report_count: int = 0
391
+ workflow_stage_states: tuple[tuple[str, str], ...] = field(default_factory=tuple)
392
+ checkml_model_source: str = ""
393
+ checkml_model_name: str = ""
394
+ checkml_model_settings: tuple[str, ...] = field(default_factory=tuple)
395
+
396
+ def __post_init__(self) -> None:
397
+ """Keep the public snapshot valid even when tests construct it directly."""
398
+ object.__setattr__(self, "ignored_columns", _normalize_text_items(self.ignored_columns))
399
+ object.__setattr__(self, "advanced_settings", _normalize_text_items(self.advanced_settings))
400
+ object.__setattr__(self, "checkml_model_settings", _normalize_text_items(self.checkml_model_settings))
401
+ object.__setattr__(self, "popup_title", _bounded_popup_text(self.popup_title, _POPUP_TITLE_LIMIT))
402
+ object.__setattr__(self, "popup_text", _bounded_popup_text(self.popup_text, _POPUP_TEXT_LIMIT))
403
+ object.__setattr__(self, "popup_buttons", tuple(_popup_buttons({"buttons": self.popup_buttons})))
404
+ object.__setattr__(self, "popup_kind", _bounded_popup_text(self.popup_kind, _POPUP_TAG_LIMIT).lower())
405
+ object.__setattr__(self, "popup_source", _bounded_popup_text(self.popup_source, _POPUP_TAG_LIMIT).lower())
406
+ if self.popup_active:
407
+ object.__setattr__(self, "popup_age_seconds", None)
408
+ return
409
+ age = _popup_age(self.popup_age_seconds)
410
+ if age is not None:
411
+ object.__setattr__(self, "popup_age_seconds", age)
412
+ return
413
+ object.__setattr__(self, "popup_title", "")
414
+ object.__setattr__(self, "popup_text", "")
415
+ object.__setattr__(self, "popup_buttons", ())
416
+ object.__setattr__(self, "popup_kind", "")
417
+ object.__setattr__(self, "popup_source", "")
418
+ object.__setattr__(self, "popup_age_seconds", None)
419
+
420
+
421
+ def active_gui_page(window: Any) -> str:
422
+ """Return the page shown by the visible GUI surface."""
423
+ tab_widget = _get_attr(window, "tab_widget", None)
424
+ current_index_accessor = _get_attr(tab_widget, "currentIndex", None)
425
+ current_index = _safe_maybe_call(current_index_accessor, default=0) if callable(current_index_accessor) else 0
426
+ active_tab = _text_from_widget(tab_widget, "tabText", "", current_index)
427
+ if not active_tab and _get_attr(window, "current_tab", None):
428
+ active_tab = str(_get_attr(window, "current_tab", ""))
429
+ elif not active_tab and _get_attr(tab_widget, "currentText", None):
430
+ active_tab = _text_from_widget(tab_widget, "currentText", "")
431
+ web_active_page = str(_get_attr(window, "web_active_page", "") or "")
432
+ if web_active_page in {"Workflow", "Advanced options", "AQME descriptors", "CheckML", "Results"}:
433
+ stack = _get_attr(window, "_ui_stack", None)
434
+ web_shell = _get_attr(window, "_web_shell", None)
435
+ web_view = _get_attr(web_shell, "view", None)
436
+ if stack is None or (web_view is not None and _safe_maybe_call(
437
+ _get_attr(stack, "currentWidget", None), default=None,
438
+ ) is web_view):
439
+ active_tab = web_active_page
440
+ return active_tab
441
+
442
+
443
+ def build_gui_snapshot(window: Any) -> GuiSnapshot:
444
+ tab_widget = _get_attr(window, "tab_widget", None)
445
+ active_tab = active_gui_page(window)
446
+
447
+ result_view = active_tab in {"Results", "Reports", "Images", "Predictions"}
448
+ result_source = str(_get_attr(window, "_result_view_source_path", "") or "") if result_view else ""
449
+ checkml_candidate = _get_attr(window, "checkml_tab", None)
450
+ checkml_tab = checkml_candidate if (
451
+ _get_attr(window, "app_mode", "easyrob") == "checkml"
452
+ or
453
+ active_tab == "CheckML"
454
+ or (result_source and _get_attr(window, "_result_view_source_kind", "ROBERT") == "CHECKML")
455
+ ) else None
456
+ input_view = checkml_tab if checkml_tab is not None else window
457
+ workflow_selector = _get_attr(window, "workflow_selector", None)
458
+ workflow = "CHECKML" if checkml_tab is not None else _text_from_widget(workflow_selector, "currentText", "")
459
+
460
+ main_csv_path = result_source or str(
461
+ _get_attr(input_view, "csv_path", None)
462
+ or _get_attr(input_view, "file_path", None)
463
+ or _get_attr(input_view, "main_csv_path", None)
464
+ or _get_attr(window, "_result_view_source_path", None)
465
+ or ""
466
+ )
467
+ test_csv_path = str(
468
+ _get_attr(input_view, "csv_test_path", None)
469
+ or _get_attr(input_view, "test_csv_path", None)
470
+ or ""
471
+ )
472
+
473
+ target_column = _text_from_widget(_get_attr(input_view, "y_dropdown", None), "currentText", "")
474
+ if not target_column:
475
+ target_column = str(_get_attr(input_view, "target_column", "") or "")
476
+
477
+ prediction_type = _text_from_widget(_get_attr(input_view, "type_dropdown", None), "currentText", "")
478
+ if not prediction_type:
479
+ prediction_type = str(_get_attr(input_view, "prediction_type", "") or "")
480
+
481
+ name_column = _text_from_widget(_get_attr(input_view, "names_dropdown", None), "currentText", "")
482
+
483
+ run_enabled = _is_enabled(_get_attr(input_view, "run_button", None))
484
+ stop_enabled = _is_enabled(_get_attr(input_view, "stop_button", None))
485
+ process_running = _is_process_running(input_view, run_enabled, stop_enabled)
486
+ active_process = (
487
+ "CHECKML" if checkml_tab is not None else str(_get_attr(window, "current_process", "") or "").strip()
488
+ ) if process_running else ""
489
+ run_aqme_enabled = _is_enabled(_get_attr(window, "run_aqme_button", None))
490
+ if checkml_tab is not None:
491
+ ignored_columns = _collect_checked_list_widget_text(_get_attr(checkml_tab, "ignore_list", None))
492
+ advanced_settings = ()
493
+ else:
494
+ ignored_columns = _collect_list_widget_text(_get_attr(window, "ignore_list", None))
495
+ advanced_settings = _collect_advanced_settings(_get_attr(window, "options_tab", None))
496
+ checkml_model_source = _text_from_widget(
497
+ _get_attr(checkml_tab, "model_source_dropdown", None), "currentText", "",
498
+ )
499
+ checkml_model_name = ""
500
+ checkml_model_settings: tuple[str, ...] = ()
501
+ checkml_source_index = _safe_maybe_call(
502
+ _get_attr(_get_attr(checkml_tab, "model_source_dropdown", None), "currentIndex", None),
503
+ default=-1,
504
+ )
505
+ if checkml_source_index == 1:
506
+ checkml_model_name = _text_from_widget(
507
+ _get_attr(checkml_tab, "sklearn_model_dropdown", None), "currentText", "",
508
+ )
509
+ fields = _get_attr(checkml_tab, "sklearn_param_fields", {})
510
+ if isinstance(fields, dict):
511
+ checkml_model_settings = _normalize_text_items([
512
+ f"{name}={value}" for name, widget in fields.items()
513
+ if (value := _text_from_widget(widget, "text", "").strip())
514
+ ])
515
+ elif checkml_source_index in {2, 3}:
516
+ attribute = "model_params_path" if checkml_source_index == 2 else "model_file_path"
517
+ value = str(_get_attr(checkml_tab, attribute, "") or "")
518
+ if value:
519
+ checkml_model_settings = _normalize_text_items([f"{attribute}={value}"])
520
+
521
+ workflow_stage_states: tuple[tuple[str, str], ...] = ()
522
+ if checkml_tab is None:
523
+ progress = _get_attr(window, "workflow_progress", None)
524
+ if progress is not None:
525
+ aqme_status = _safe_maybe_call(_get_attr(progress, "aqme_status", None), default="")
526
+ stage_statuses = _safe_maybe_call(_get_attr(progress, "statuses", None), default=())
527
+ if isinstance(aqme_status, str) and isinstance(stage_statuses, (list, tuple)):
528
+ workflow_stage_states = tuple(
529
+ (name, state) for name, state in zip(
530
+ ("AQME", "CURATE", "GENERATE", "VERIFY", "PREDICT", "REPORT"),
531
+ (aqme_status, *stage_statuses),
532
+ ) if isinstance(state, str)
533
+ )
534
+ enabled_tabs, disabled_tabs = _collect_tab_states(tab_widget)
535
+ result_model = ""
536
+ result_models: tuple[str, ...] = ()
537
+ result_selected_variants: tuple[tuple[str, str], ...] = ()
538
+ result_active_view = ""
539
+ result_enabled_views: tuple[str, ...] = ()
540
+ result_disabled_views: tuple[str, ...] = ()
541
+ result_root_reports: tuple[str, ...] = ()
542
+ result_archived_report_count = 0
543
+ catalog = _get_attr(window, "_result_catalog", None)
544
+ workspace = _get_attr(window, "results_workspace", None)
545
+ if catalog is not None and workspace is not None and main_csv_path:
546
+ try:
547
+ same_run = Path(main_csv_path).resolve().parent == Path(catalog.root).resolve()
548
+ except (OSError, ValueError, TypeError):
549
+ same_run = False
550
+ if same_run:
551
+ try:
552
+ result_root_reports = tuple(sorted(
553
+ path.name for path in Path(catalog.root).glob("ROBERT_report_*.pdf") if path.is_file()
554
+ ))
555
+ result_archived_report_count = sum(
556
+ 1 for path in (Path(catalog.root) / "REPORT_models").glob("ROBERT_report_*.pdf")
557
+ if path.is_file()
558
+ )
559
+ except OSError:
560
+ pass
561
+ result_models = tuple(str(model) for model in _get_attr(catalog, "models", ())) if _get_attr(catalog, "is_all_models", False) else ()
562
+ current_model = _safe_maybe_call(_get_attr(workspace, "current_model", None), default=None)
563
+ result_model = str(current_model) if current_model else "Best models" if result_models else ""
564
+ selected = _safe_maybe_call(_get_attr(catalog, "selected_variants", None), current_model, default={}) if result_models else {}
565
+ if isinstance(selected, dict):
566
+ result_selected_variants = tuple((str(variant), str(model)) for variant, model in selected.items())
567
+ buttons = _get_attr(workspace, "buttons", {})
568
+ if isinstance(buttons, dict):
569
+ result_enabled_views = tuple(name for name, button in buttons.items() if _is_enabled(button))
570
+ result_disabled_views = tuple(name for name, button in buttons.items() if not _is_enabled(button))
571
+ result_active_view = next((name for name, button in buttons.items() if _checked(button)), "")
572
+ if active_tab == "Results":
573
+ web_result_view = str(_get_attr(window, "web_active_result_view", "") or "")
574
+ if web_result_view in {"Report", "Predictions", "Images", "Interactive plots"}:
575
+ result_active_view = web_result_view
576
+
577
+ console_output = _get_attr(input_view, "console_output", None)
578
+ recent_console = _recent_console_slice(_text_from_widget(console_output, "toPlainText", ""))
579
+ console_terms = _append_console_phrase_markers(recent_console, _tokenize(recent_console))
580
+ parsed_failure = parse_python_failure(recent_console)
581
+
582
+ aqme_workflow = _get_attr(window, "aqme_workflow", None)
583
+ aqme_checked_accessor = _get_attr(aqme_workflow, "isChecked", None)
584
+ aqme_workflow_enabled = bool(_safe_maybe_call(aqme_checked_accessor, default=False)) if callable(aqme_checked_accessor) else False
585
+ active_popup = _get_attr(window, "bot_active_popup", None)
586
+ popup_context = _get_attr(window, "bot_popup_context", None)
587
+ popup_context_age_seconds = _popup_age(_get_attr(window, "bot_popup_context_age_seconds", None))
588
+ has_active_popup = active_popup is not None
589
+ effective_popup = active_popup if has_active_popup else None
590
+ effective_popup_age_seconds = None
591
+ if not has_active_popup and popup_context is not None:
592
+ is_fresh = popup_context_age_seconds is not None
593
+ if is_fresh:
594
+ effective_popup = popup_context
595
+ effective_popup_age_seconds = popup_context_age_seconds
596
+ aqme_tab = _get_attr(window, "tab_widget_aqme", None)
597
+ smarts_targets = _get_attr(aqme_tab, "smarts_targets", [])
598
+ aqme_smarts_pattern = ""
599
+ if isinstance(smarts_targets, (list, tuple)) and smarts_targets:
600
+ aqme_smarts_pattern = str(smarts_targets[0] or "")
601
+ elif smarts_targets:
602
+ aqme_smarts_pattern = str(smarts_targets or "")
603
+ aqme_message_text = str(_get_attr(aqme_tab, "bot_context_message", "") or "")
604
+ aqme_message_tooltip = str(_get_attr(aqme_tab, "bot_context_tooltip", "") or "")
605
+ aqme_info_text = str(_get_attr(aqme_tab, "bot_context_info", "") or "")
606
+ if not aqme_info_text:
607
+ aqme_info_text = _text_from_widget(_get_attr(aqme_tab, "mol_info_label", None), "text", "")
608
+ aqme_descriptor_level = _text_from_widget(_get_attr(aqme_tab, "descriptor_level", None), "currentText", "")
609
+ aqme_solvent = _text_from_widget(_get_attr(aqme_tab, "solvent", None), "currentText", "")
610
+ aqme_atoms_text = _text_from_widget(_get_attr(aqme_tab, "atoms", None), "text", "")
611
+ aqme_selected_atoms = _normalize_int_list(_get_attr(aqme_tab, "selected_atoms", []))
612
+ aqme_multiple_matches_detected = bool(_get_attr(aqme_tab, "multiple_matches_detected", False))
613
+ aqme_metal_found = bool(_get_attr(aqme_tab, "metal_found", False))
614
+ unified_smiles = _get_attr(aqme_tab, "unified_smiles", [])
615
+ aqme_unified_smiles_count = len(unified_smiles) if isinstance(unified_smiles, (list, tuple, set)) else 0
616
+
617
+ return GuiSnapshot(
618
+ active_tab=active_tab,
619
+ workflow=workflow,
620
+ main_csv_path=main_csv_path,
621
+ test_csv_path=test_csv_path,
622
+ target_column=target_column,
623
+ prediction_type=prediction_type,
624
+ process_running=process_running,
625
+ run_enabled=run_enabled,
626
+ stop_enabled=stop_enabled,
627
+ recent_console=recent_console,
628
+ console_terms=console_terms,
629
+ name_column=name_column,
630
+ active_process=active_process,
631
+ run_aqme_enabled=run_aqme_enabled,
632
+ ignored_columns=ignored_columns,
633
+ advanced_settings=advanced_settings,
634
+ aqme_workflow_enabled=aqme_workflow_enabled,
635
+ enabled_tabs=enabled_tabs,
636
+ disabled_tabs=disabled_tabs,
637
+ popup_active=has_active_popup,
638
+ popup_title=_bounded_popup_text(_popup_value(effective_popup, "title", ""), _POPUP_TITLE_LIMIT),
639
+ popup_text=_bounded_popup_text(_popup_value(effective_popup, "text", ""), _POPUP_TEXT_LIMIT),
640
+ popup_buttons=_popup_buttons(effective_popup),
641
+ popup_kind=_bounded_popup_text(_popup_value(effective_popup, "kind", ""), _POPUP_TAG_LIMIT).lower(),
642
+ popup_source=_bounded_popup_text(_popup_value(effective_popup, "source", ""), _POPUP_TAG_LIMIT).lower(),
643
+ popup_age_seconds=effective_popup_age_seconds,
644
+ failure_type=parsed_failure.failure_type,
645
+ failure_message=parsed_failure.failure_message,
646
+ failure_location=parsed_failure.failure_location,
647
+ failure_function=parsed_failure.failure_function,
648
+ failure_operation=parsed_failure.failure_operation,
649
+ likely_cause=parsed_failure.likely_cause,
650
+ aqme_smarts_pattern=aqme_smarts_pattern,
651
+ aqme_message_text=aqme_message_text,
652
+ aqme_message_tooltip=aqme_message_tooltip,
653
+ aqme_info_text=aqme_info_text,
654
+ aqme_selected_atoms=aqme_selected_atoms,
655
+ aqme_descriptor_level=aqme_descriptor_level,
656
+ aqme_solvent=aqme_solvent,
657
+ aqme_atoms_text=aqme_atoms_text,
658
+ aqme_multiple_matches_detected=aqme_multiple_matches_detected,
659
+ aqme_metal_found=aqme_metal_found,
660
+ aqme_unified_smiles_count=aqme_unified_smiles_count,
661
+ workflow_results=(
662
+ _get_attr(window, "workflow_result_snapshot", None)
663
+ if isinstance(_get_attr(window, "workflow_result_snapshot", None), WorkflowResultSnapshot)
664
+ else None
665
+ ),
666
+ result_model=result_model,
667
+ result_models=result_models,
668
+ result_selected_variants=result_selected_variants,
669
+ result_active_view=result_active_view,
670
+ result_enabled_views=result_enabled_views,
671
+ result_disabled_views=result_disabled_views,
672
+ all_models_enabled=_checked(_get_attr(window, "all_models_toggle", None)),
673
+ result_root_reports=result_root_reports,
674
+ result_archived_report_count=result_archived_report_count,
675
+ workflow_stage_states=workflow_stage_states,
676
+ checkml_model_source=checkml_model_source,
677
+ checkml_model_name=checkml_model_name,
678
+ checkml_model_settings=checkml_model_settings,
679
+ )