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.
- robert/__init__.py +9 -0
- robert/__main__.py +20 -0
- robert/_version.py +3 -0
- robert/api.py +646 -0
- robert/aqme.py +280 -0
- robert/argument_parser.py +98 -0
- robert/checkml.py +433 -0
- robert/checkml_score.py +50 -0
- robert/curate.py +217 -0
- robert/evaluate_bot_retrieval.py +125 -0
- robert/evaluate_bot_support.py +102 -0
- robert/evaluate_workflow_summaries.py +87 -0
- robert/export_bot_docs_knowledge.py +1632 -0
- robert/generate.py +249 -0
- robert/generate_utils.py +311 -0
- robert/gui_easyrob/__init__.py +0 -0
- robert/gui_easyrob/assets/gif_easyrob.gif +0 -0
- robert/gui_easyrob/bot/__init__.py +47 -0
- robert/gui_easyrob/bot/answer_metadata.py +198 -0
- robert/gui_easyrob/bot/bot_context.py +679 -0
- robert/gui_easyrob/bot/bot_engine.py +1100 -0
- robert/gui_easyrob/bot/bot_panel.py +1231 -0
- robert/gui_easyrob/bot/bot_rag.py +1178 -0
- robert/gui_easyrob/bot/bot_window.py +39 -0
- robert/gui_easyrob/bot/bot_worker.py +149 -0
- robert/gui_easyrob/bot/credential_store.py +143 -0
- robert/gui_easyrob/bot/error_parser.py +105 -0
- robert/gui_easyrob/bot/evidence_policy.py +164 -0
- robert/gui_easyrob/bot/heuristics.py +859 -0
- robert/gui_easyrob/bot/icons.py +56 -0
- robert/gui_easyrob/bot/input_csv_audit.py +212 -0
- robert/gui_easyrob/bot/knowledge/aqme_context.json +5907 -0
- robert/gui_easyrob/bot/knowledge/robert_context.json +4817 -0
- robert/gui_easyrob/bot/knowledge/ui_context.json +8293 -0
- robert/gui_easyrob/bot/knowledge_schema.py +1252 -0
- robert/gui_easyrob/bot/knowledge_sources/aqme_user_guidance.json +442 -0
- robert/gui_easyrob/bot/knowledge_sources/coverage_manifest.json +95 -0
- robert/gui_easyrob/bot/knowledge_sources/robert_user_guidance.json +471 -0
- robert/gui_easyrob/bot/knowledge_sources/ui_user_guidance.json +1312 -0
- robert/gui_easyrob/bot/llm_providers.py +1573 -0
- robert/gui_easyrob/bot/online_docs.py +105 -0
- robert/gui_easyrob/bot/prompt_policy.py +575 -0
- robert/gui_easyrob/bot/question_intent.py +562 -0
- robert/gui_easyrob/bot/response_quality.py +104 -0
- robert/gui_easyrob/bot/result_insights.py +225 -0
- robert/gui_easyrob/bot/token_usage.py +75 -0
- robert/gui_easyrob/bot/workflow_results.py +1396 -0
- robert/gui_easyrob/checkml_launcher.py +15 -0
- robert/gui_easyrob/easyrob.py +29 -0
- robert/gui_easyrob/easyrob_launcher.py +113 -0
- robert/gui_easyrob/main/__init__.py +9 -0
- robert/gui_easyrob/main/window.py +5152 -0
- robert/gui_easyrob/result_navigation.py +14 -0
- robert/gui_easyrob/tabs/__init__.py +23 -0
- robert/gui_easyrob/tabs/advanced_options.py +370 -0
- robert/gui_easyrob/tabs/aqme.py +1234 -0
- robert/gui_easyrob/tabs/checkml.py +898 -0
- robert/gui_easyrob/tabs/images.py +427 -0
- robert/gui_easyrob/tabs/interactive_predictions.py +555 -0
- robert/gui_easyrob/tabs/molssi.py +447 -0
- robert/gui_easyrob/tabs/predictions.py +484 -0
- robert/gui_easyrob/tabs/result_catalog.py +170 -0
- robert/gui_easyrob/tabs/results.py +490 -0
- robert/gui_easyrob/tabs/results_workspace.py +120 -0
- robert/gui_easyrob/test_bot_input_csv_audit.py +152 -0
- robert/gui_easyrob/test_bot_question_routing.py +383 -0
- robert/gui_easyrob/test_bot_result_analysis.py +356 -0
- robert/gui_easyrob/test_bot_retrieval_evaluation.py +110 -0
- robert/gui_easyrob/test_bot_ui_integration.py +278 -0
- robert/gui_easyrob/test_checkml_app_mode.py +124 -0
- robert/gui_easyrob/test_checkml_completion.py +57 -0
- robert/gui_easyrob/test_checkml_defaults.py +37 -0
- robert/gui_easyrob/test_checkml_result_summary.py +113 -0
- robert/gui_easyrob/test_checkml_web_mode.py +57 -0
- robert/gui_easyrob/test_dialog_layout.py +33 -0
- robert/gui_easyrob/test_gui_bot_regressions.py +320 -0
- robert/gui_easyrob/test_molssi_auto.py +569 -0
- robert/gui_easyrob/test_tutorial_view.py +215 -0
- robert/gui_easyrob/tutorials/check_model.md +25 -0
- robert/gui_easyrob/tutorials/chemdraw.md +49 -0
- robert/gui_easyrob/tutorials/csv.md +53 -0
- robert/gui_easyrob/tutorials/descriptors.md +21 -0
- robert/gui_easyrob/tutorials/overview.md +65 -0
- robert/gui_easyrob/tutorials/predictions.md +25 -0
- robert/gui_easyrob/tutorials/robbot.md +29 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_10.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_11.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_12.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_13.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_9.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_9.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_8.png +0 -0
- robert/gui_easyrob/utils/__init__.py +0 -0
- robert/gui_easyrob/utils/aqme_utils.py +238 -0
- robert/gui_easyrob/utils/molssi_utils.py +584 -0
- robert/gui_easyrob/utils/predictions_utils.py +985 -0
- robert/gui_easyrob/utils/utils_gui.py +738 -0
- robert/gui_easyrob/version.py +68 -0
- robert/gui_easyrob/web/app.css +484 -0
- robert/gui_easyrob/web/app.html +134 -0
- robert/gui_easyrob/web/app.js +764 -0
- robert/gui_easyrob/web/checkml_brand.png +0 -0
- robert/gui_easyrob/web/easyrob_background.gif +0 -0
- robert/gui_easyrob/web/easyrob_background.png +0 -0
- robert/gui_easyrob/web/images.css +89 -0
- robert/gui_easyrob/web/images.html +39 -0
- robert/gui_easyrob/web/images.js +101 -0
- robert/gui_easyrob/web/results.js +499 -0
- robert/gui_easyrob/web/robert_brand.png +0 -0
- robert/gui_easyrob/web_dialogs.py +64 -0
- robert/gui_easyrob/web_results.py +253 -0
- robert/gui_easyrob/web_shell.py +684 -0
- robert/gui_easyrob/workflow_progress.py +89 -0
- robert/gui_easyrob/workflow_run_lock.py +27 -0
- robert/icons/CheckML_icon.png +0 -0
- robert/icons/Robert_icon.png +0 -0
- robert/icons/Robert_logo.jpg +0 -0
- robert/icons/Robert_logo_transparent.png +0 -0
- robert/icons/documentation_icon.png +0 -0
- robert/icons/info_icon.png +0 -0
- robert/icons/pdf_icon.png +0 -0
- robert/icons/play_icon.png +0 -0
- robert/icons/stop_icon.png +0 -0
- robert/icons/youtube_icon.ico +0 -0
- robert/predict.py +193 -0
- robert/predict_utils.py +410 -0
- robert/report/CheckML_logo.jpg +0 -0
- robert/report/GENERATE.png +0 -0
- robert/report/Robert_icon.ico +0 -0
- robert/report/Robert_logo.jpg +0 -0
- robert/report/Robert_logo1.jpg +0 -0
- robert/report/abbrev.png +0 -0
- robert/report/adv_anal.png +0 -0
- robert/report/checkml_pass.svg +3 -0
- robert/report/checkml_unclear.svg +3 -0
- robert/report/checkml_warning.svg +3 -0
- robert/report/features.png +0 -0
- robert/report/outliers.png +0 -0
- robert/report/pred.png +0 -0
- robert/report/repro.png +0 -0
- robert/report/robust_x.png +0 -0
- robert/report/robust_y_high.png +0 -0
- robert/report/robust_y_low.png +0 -0
- robert/report/score.png +0 -0
- robert/report/score_0.jpg +0 -0
- robert/report/score_1.jpg +0 -0
- robert/report/score_10.jpg +0 -0
- robert/report/score_2.jpg +0 -0
- robert/report/score_3.jpg +0 -0
- robert/report/score_4.jpg +0 -0
- robert/report/score_5.jpg +0 -0
- robert/report/score_6.jpg +0 -0
- robert/report/score_7.jpg +0 -0
- robert/report/score_8.jpg +0 -0
- robert/report/score_9.jpg +0 -0
- robert/report/score_gray_0.jpg +0 -0
- robert/report/score_gray_1.jpg +0 -0
- robert/report/score_gray_10.jpg +0 -0
- robert/report/score_gray_2.jpg +0 -0
- robert/report/score_gray_3.jpg +0 -0
- robert/report/score_gray_4.jpg +0 -0
- robert/report/score_gray_5.jpg +0 -0
- robert/report/score_gray_6.jpg +0 -0
- robert/report/score_gray_7.jpg +0 -0
- robert/report/score_gray_8.jpg +0 -0
- robert/report/score_gray_9.jpg +0 -0
- robert/report/score_w_1_0.jpg +0 -0
- robert/report/score_w_1_1.jpg +0 -0
- robert/report/score_w_2_0.jpg +0 -0
- robert/report/score_w_2_1.jpg +0 -0
- robert/report/score_w_2_2.jpg +0 -0
- robert/report/score_w_2_gray_0.jpg +0 -0
- robert/report/score_w_2_gray_1.jpg +0 -0
- robert/report/score_w_2_gray_2.jpg +0 -0
- robert/report/score_w_3_0.jpg +0 -0
- robert/report/score_w_3_1.jpg +0 -0
- robert/report/score_w_3_2.jpg +0 -0
- robert/report/score_w_3_3.jpg +0 -0
- robert/report/score_w_4_0.jpg +0 -0
- robert/report/score_w_4_1.JPG +0 -0
- robert/report/score_w_4_2.jpg +0 -0
- robert/report/score_w_4_3.jpg +0 -0
- robert/report/score_w_4_4.jpg +0 -0
- robert/report/transpa.png +0 -0
- robert/report/y_distrib.png +0 -0
- robert/report.py +2880 -0
- robert/report_utils.py +2270 -0
- robert/robert.py +181 -0
- robert/utils.py +4763 -0
- robert/verify.py +606 -0
- robert-2.2.0.dist-info/METADATA +55 -0
- robert-2.2.0.dist-info/RECORD +261 -0
- robert-2.2.0.dist-info/WHEEL +5 -0
- robert-2.2.0.dist-info/entry_points.txt +3 -0
- robert-2.2.0.dist-info/licenses/LICENSE +21 -0
- robert-2.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
"""Web presentation for easyROB controls backed by the existing Qt workflow."""
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import csv
|
|
5
|
+
from io import BytesIO
|
|
6
|
+
import json
|
|
7
|
+
import html
|
|
8
|
+
import re
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
import pandas as pd
|
|
12
|
+
from rdkit import Chem
|
|
13
|
+
from rdkit.Chem import Draw
|
|
14
|
+
|
|
15
|
+
from PySide6.QtCore import QBuffer, QIODevice, QObject, QTimer, QUrl, QUrlQuery, Signal, Slot
|
|
16
|
+
from PySide6.QtWidgets import QCheckBox, QComboBox, QFileDialog, QLineEdit, QWidget
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
from gui_easyrob.web_results import WebResultsService
|
|
20
|
+
from gui_easyrob.bot.bot_panel import _render_markdown
|
|
21
|
+
except ImportError:
|
|
22
|
+
from robert.gui_easyrob.web_results import WebResultsService
|
|
23
|
+
from robert.gui_easyrob.bot.bot_panel import _render_markdown
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
FIELD_GROUPS = {
|
|
27
|
+
"workflow": (
|
|
28
|
+
("y_dropdown", "Target column"),
|
|
29
|
+
("type_dropdown", "Prediction type"),
|
|
30
|
+
("names_dropdown", "Name column"),
|
|
31
|
+
("workflow_selector", "Workflow"),
|
|
32
|
+
("aqme_workflow", "Calculate descriptors with AQME"),
|
|
33
|
+
("all_models_toggle", "Report every selected model"),
|
|
34
|
+
),
|
|
35
|
+
"general": (
|
|
36
|
+
("auto_type", "Automatic prediction type"),
|
|
37
|
+
("seed", "Random seed"),
|
|
38
|
+
("kfold", "Cross-validation folds"),
|
|
39
|
+
("repeat_kfolds", "Cross-validation repeats"),
|
|
40
|
+
("split", "Split method"),
|
|
41
|
+
),
|
|
42
|
+
"curate": (
|
|
43
|
+
("categoricalstr", "Categorical encoding"),
|
|
44
|
+
("corr_filter_xbool", "Descriptor correlation filter"),
|
|
45
|
+
("corr_filter_ybool", "Target correlation filter"),
|
|
46
|
+
("rfecv_filterbool", "RFECV filter"),
|
|
47
|
+
("thres_xfloat", "Descriptor correlation threshold"),
|
|
48
|
+
("thres_yfloat", "Target correlation threshold"),
|
|
49
|
+
),
|
|
50
|
+
"generate": (
|
|
51
|
+
("error_type", "Optimization metric"),
|
|
52
|
+
("init_points", "Initial points"),
|
|
53
|
+
("n_iter", "Optimization iterations"),
|
|
54
|
+
("expect_improv", "Expected improvement"),
|
|
55
|
+
("pfi_filter", "PFI filter"),
|
|
56
|
+
("pfi_epochs", "PFI epochs"),
|
|
57
|
+
("pfi_threshold", "PFI threshold"),
|
|
58
|
+
("pfi_max", "Maximum PFI features"),
|
|
59
|
+
("auto_test", "Automatic test split"),
|
|
60
|
+
("test_set", "Test set size"),
|
|
61
|
+
),
|
|
62
|
+
"predict": (
|
|
63
|
+
("t_value", "t value"),
|
|
64
|
+
("shap_show", "SHAP plots"),
|
|
65
|
+
("pfi_show", "PFI plots"),
|
|
66
|
+
),
|
|
67
|
+
"aqme": (
|
|
68
|
+
("atoms", "QDESCP atoms"),
|
|
69
|
+
("descriptor_level", "Descriptor level"),
|
|
70
|
+
("solvent", "Solvent"),
|
|
71
|
+
),
|
|
72
|
+
"checkml": (
|
|
73
|
+
("y_dropdown", "Target column"),
|
|
74
|
+
("names_dropdown", "Name column"),
|
|
75
|
+
("type_dropdown", "Prediction type"),
|
|
76
|
+
("model_source_dropdown", "Model source"),
|
|
77
|
+
("sklearn_model_dropdown", "Scikit-learn model"),
|
|
78
|
+
),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class WorkflowBridge(QObject):
|
|
83
|
+
"""Translate a small allowlisted web API into existing Qt widget actions."""
|
|
84
|
+
|
|
85
|
+
stateChanged = Signal(str)
|
|
86
|
+
logChanged = Signal(str)
|
|
87
|
+
chemdrawReady = Signal(str)
|
|
88
|
+
|
|
89
|
+
def __init__(self, window):
|
|
90
|
+
super().__init__(window)
|
|
91
|
+
self.window = window
|
|
92
|
+
self._results = WebResultsService(window)
|
|
93
|
+
self._last_state = ""
|
|
94
|
+
self._log_snapshots = {"workflow": "", "checkml": ""}
|
|
95
|
+
self._log_revisions = {"workflow": None, "checkml": None}
|
|
96
|
+
self._molecule_cache_key = None
|
|
97
|
+
self._molecule_image = ""
|
|
98
|
+
self._chemdraw_rows = []
|
|
99
|
+
self._timer = QTimer(self)
|
|
100
|
+
self._timer.setInterval(1200)
|
|
101
|
+
self._timer.timeout.connect(self.push_state)
|
|
102
|
+
self._timer.start()
|
|
103
|
+
|
|
104
|
+
def _owner(self, group):
|
|
105
|
+
if group == "workflow":
|
|
106
|
+
return self.window
|
|
107
|
+
if group in {"general", "curate", "generate", "predict"}:
|
|
108
|
+
return self.window.options_tab
|
|
109
|
+
if group == "aqme":
|
|
110
|
+
return self.window.tab_widget_aqme
|
|
111
|
+
if group == "checkml":
|
|
112
|
+
return self.window.checkml_tab
|
|
113
|
+
return None
|
|
114
|
+
|
|
115
|
+
def _widget(self, key):
|
|
116
|
+
group, separator, name = key.partition(".")
|
|
117
|
+
if not separator or name not in {item[0] for item in FIELD_GROUPS.get(group, ())}:
|
|
118
|
+
return None
|
|
119
|
+
return getattr(self._owner(group), name, None)
|
|
120
|
+
|
|
121
|
+
@staticmethod
|
|
122
|
+
def _field(key, label, widget):
|
|
123
|
+
field = {"key": key, "label": label, "enabled": widget.isEnabled()}
|
|
124
|
+
if isinstance(widget, QComboBox):
|
|
125
|
+
field.update({
|
|
126
|
+
"type": "select",
|
|
127
|
+
"value": widget.currentText(),
|
|
128
|
+
"options": [widget.itemText(index) for index in range(widget.count())],
|
|
129
|
+
})
|
|
130
|
+
elif isinstance(widget, QLineEdit):
|
|
131
|
+
field.update({"type": "text", "value": widget.text(), "placeholder": widget.placeholderText()})
|
|
132
|
+
else:
|
|
133
|
+
field.update({"type": "toggle", "value": widget.isChecked()})
|
|
134
|
+
return field
|
|
135
|
+
|
|
136
|
+
def _molecule_state(self):
|
|
137
|
+
tab = self.window.tab_widget_aqme
|
|
138
|
+
pixmap = tab.mol_viewer.pixmap()
|
|
139
|
+
cache_key = pixmap.cacheKey() if pixmap is not None and not pixmap.isNull() else None
|
|
140
|
+
if cache_key != self._molecule_cache_key:
|
|
141
|
+
self._molecule_cache_key = cache_key
|
|
142
|
+
self._molecule_image = ""
|
|
143
|
+
if cache_key is not None:
|
|
144
|
+
buffer = QBuffer()
|
|
145
|
+
buffer.open(QIODevice.OpenModeFlag.WriteOnly)
|
|
146
|
+
if pixmap.save(buffer, "PNG"):
|
|
147
|
+
self._molecule_image = "data:image/png;base64," + bytes(buffer.data().toBase64()).decode("ascii")
|
|
148
|
+
def plain_text(value):
|
|
149
|
+
return html.unescape(re.sub(r"<[^>]*>", "", value or ""))
|
|
150
|
+
return {
|
|
151
|
+
"image": self._molecule_image,
|
|
152
|
+
"message": plain_text(tab.mol_viewer.text()) if not self._molecule_image else "",
|
|
153
|
+
"info": plain_text(tab.mol_info_label.text()),
|
|
154
|
+
"selectedAtoms": len(tab.selected_atoms),
|
|
155
|
+
"canSelect": bool(self._molecule_image and tab.smarts_targets)
|
|
156
|
+
and not (getattr(tab, "metal_found", False) and getattr(tab, "multiple_matches_detected", False)),
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
def _bot_state(self):
|
|
160
|
+
panel = self.window.bot_panel
|
|
161
|
+
return {
|
|
162
|
+
"mode": panel.mode_combo.currentText(),
|
|
163
|
+
"modes": [panel.mode_combo.itemText(index) for index in range(panel.mode_combo.count())],
|
|
164
|
+
"provider": panel.provider_combo.currentText(),
|
|
165
|
+
"providers": [panel.provider_combo.itemText(index) for index in range(panel.provider_combo.count())],
|
|
166
|
+
"webSearch": panel.web_search_checkbox.isChecked(),
|
|
167
|
+
"apiSaved": bool(panel.delete_api_button.property("has_saved_api")),
|
|
168
|
+
"draft": panel.input_edit.text(),
|
|
169
|
+
"canSend": panel.send_button.isEnabled(),
|
|
170
|
+
"busy": bool(panel._busy),
|
|
171
|
+
"messages": [
|
|
172
|
+
{"role": role, "content": content, "html": _render_markdown(content)}
|
|
173
|
+
for role, content in panel._message_records[-80:]
|
|
174
|
+
],
|
|
175
|
+
"lastUsage": panel.last_usage_label.text(),
|
|
176
|
+
"sessionUsage": panel.session_usage_label.text(),
|
|
177
|
+
"requestStage": panel.request_stage_label.text(),
|
|
178
|
+
"suggestions": [
|
|
179
|
+
{"label": panel.suggested_combo.itemText(index), "index": index}
|
|
180
|
+
for index in range(1, panel.suggested_combo.count())
|
|
181
|
+
],
|
|
182
|
+
"canSummarize": panel.workflow_summary_button.isEnabled(),
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
def _state(self):
|
|
186
|
+
window = self.window
|
|
187
|
+
groups = {}
|
|
188
|
+
for group, entries in FIELD_GROUPS.items():
|
|
189
|
+
owner = self._owner(group)
|
|
190
|
+
groups[group] = [
|
|
191
|
+
self._field(f"{group}.{name}", label, getattr(owner, name))
|
|
192
|
+
for name, label in entries
|
|
193
|
+
if getattr(owner, name, None) is not None
|
|
194
|
+
and (group != "checkml" or name != "sklearn_model_dropdown"
|
|
195
|
+
or window.checkml_tab.model_source_dropdown.currentIndex() == 1)
|
|
196
|
+
]
|
|
197
|
+
groups["generate"].extend(
|
|
198
|
+
self._field(f"model.{name}", name, widget)
|
|
199
|
+
for name, widget in window.options_tab.modellist.items()
|
|
200
|
+
)
|
|
201
|
+
checkml = window.checkml_tab
|
|
202
|
+
if checkml.model_source_dropdown.currentIndex() == 1:
|
|
203
|
+
groups["checkml"].extend(
|
|
204
|
+
self._field(f"checkml_param.{name}", name, widget)
|
|
205
|
+
for name, widget in checkml.sklearn_param_fields.items()
|
|
206
|
+
)
|
|
207
|
+
progress = getattr(window, "workflow_progress", None)
|
|
208
|
+
return {
|
|
209
|
+
"groups": groups,
|
|
210
|
+
"files": {
|
|
211
|
+
"train": window.file_path or "",
|
|
212
|
+
"test": window.csv_test_path or "",
|
|
213
|
+
"checkmlTrain": checkml.csv_path or "",
|
|
214
|
+
"checkmlTest": checkml.csv_test_path or "",
|
|
215
|
+
"checkmlParams": checkml.model_params_path or "",
|
|
216
|
+
"checkmlModel": checkml.model_file_path or "",
|
|
217
|
+
},
|
|
218
|
+
"columns": {
|
|
219
|
+
"available": [window.available_list.item(index).text() for index in range(window.available_list.count())],
|
|
220
|
+
"ignored": [window.ignore_list.item(index).text() for index in range(window.ignore_list.count())],
|
|
221
|
+
},
|
|
222
|
+
"checkmlSource": checkml.model_source_dropdown.currentIndex(),
|
|
223
|
+
"actions": {
|
|
224
|
+
"run": window.run_button.isEnabled(),
|
|
225
|
+
"runAqme": window.run_aqme_button.isEnabled(),
|
|
226
|
+
"stop": window.stop_button.isEnabled(),
|
|
227
|
+
"checkmlRun": checkml.run_button.isEnabled(),
|
|
228
|
+
"checkmlStop": checkml.stop_button.isEnabled(),
|
|
229
|
+
"results": window.results_workspace.has_available_views(),
|
|
230
|
+
"aqme": window.tab_widget.isTabEnabled(window.tab_widget.indexOf(window.tab_widget_aqme)),
|
|
231
|
+
},
|
|
232
|
+
"results": {
|
|
233
|
+
"revision": getattr(window, "_results_revision", 0),
|
|
234
|
+
"available": dict(window.results_workspace._available),
|
|
235
|
+
"models": [
|
|
236
|
+
{"label": window.results_workspace.model_selector.itemText(index),
|
|
237
|
+
"value": window.results_workspace.model_selector.itemData(index) or ""}
|
|
238
|
+
for index in range(window.results_workspace.model_selector.count())
|
|
239
|
+
],
|
|
240
|
+
"selectedModel": window.results_workspace.current_model() or "",
|
|
241
|
+
"predictionFiles": [
|
|
242
|
+
{"key": key, "label": key.replace("_", " ")}
|
|
243
|
+
for key in window.predictions_tab.csv_paths
|
|
244
|
+
],
|
|
245
|
+
"files": {
|
|
246
|
+
"Report": [Path(path).name for path in window.results_tab.pdf_tabs],
|
|
247
|
+
"Predictions": [Path(path).name for path in window.predictions_tab.csv_paths.values()],
|
|
248
|
+
"Interactive plots": [Path(path).name for path in window.interactive_plots.paths],
|
|
249
|
+
},
|
|
250
|
+
"gallery": window.images_tab.gallery_state,
|
|
251
|
+
},
|
|
252
|
+
"molecule": self._molecule_state(),
|
|
253
|
+
"bot": self._bot_state(),
|
|
254
|
+
"progress": [label.text() for label in window.workflow_stage_status_labels],
|
|
255
|
+
"progressStates": list(progress.statuses()) if progress else ["idle"] * 5,
|
|
256
|
+
"aqmeProgress": progress.aqme_status() if progress else (
|
|
257
|
+
"idle" if window.aqme_workflow.isChecked() else "inactive"
|
|
258
|
+
),
|
|
259
|
+
"activity": "" if window.workflow_activity_label.isHidden() else window.workflow_activity_label.text(),
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
@Slot(result=str)
|
|
263
|
+
def getState(self):
|
|
264
|
+
state = self._state()
|
|
265
|
+
state["log"] = self.window.console_output.toPlainText()
|
|
266
|
+
state["checkmlLog"] = self.window.checkml_tab.console_output.toPlainText()
|
|
267
|
+
return json.dumps(state, ensure_ascii=False)
|
|
268
|
+
|
|
269
|
+
@Slot(result=str)
|
|
270
|
+
def getLogs(self):
|
|
271
|
+
return json.dumps({
|
|
272
|
+
"workflow": self.window.console_output.toPlainText(),
|
|
273
|
+
"checkml": self.window.checkml_tab.console_output.toPlainText(),
|
|
274
|
+
}, ensure_ascii=False)
|
|
275
|
+
|
|
276
|
+
def _push_logs(self):
|
|
277
|
+
editors = {
|
|
278
|
+
"workflow": self.window.console_output,
|
|
279
|
+
"checkml": self.window.checkml_tab.console_output,
|
|
280
|
+
}
|
|
281
|
+
for kind, editor in editors.items():
|
|
282
|
+
revision = editor.document().revision()
|
|
283
|
+
if revision == self._log_revisions[kind]:
|
|
284
|
+
continue
|
|
285
|
+
self._log_revisions[kind] = revision
|
|
286
|
+
current = editor.toPlainText()
|
|
287
|
+
previous = self._log_snapshots[kind]
|
|
288
|
+
if current == previous:
|
|
289
|
+
continue
|
|
290
|
+
replace = not current.startswith(previous)
|
|
291
|
+
payload = {
|
|
292
|
+
"kind": kind,
|
|
293
|
+
"offset": 0 if replace else len(previous),
|
|
294
|
+
"text": current if replace else current[len(previous):],
|
|
295
|
+
"replace": replace,
|
|
296
|
+
}
|
|
297
|
+
self._log_snapshots[kind] = current
|
|
298
|
+
self.logChanged.emit(json.dumps(payload, ensure_ascii=False))
|
|
299
|
+
|
|
300
|
+
@Slot(result=str)
|
|
301
|
+
def getTutorials(self):
|
|
302
|
+
root = Path(__file__).resolve().parent / "tutorials"
|
|
303
|
+
topics = self.window.tutorial_topics()
|
|
304
|
+
catalog = []
|
|
305
|
+
for slug, title in topics:
|
|
306
|
+
blocks = self.window.load_tutorial(slug)
|
|
307
|
+
images = sorted(
|
|
308
|
+
(root / "tutorial_images" / slug).glob(f"{slug}_*.png"),
|
|
309
|
+
key=lambda path: tuple(
|
|
310
|
+
int(segment) if segment.isdigit() else segment
|
|
311
|
+
for segment in path.stem.split("_")
|
|
312
|
+
),
|
|
313
|
+
)
|
|
314
|
+
catalog.append({
|
|
315
|
+
"id": slug, "title": title,
|
|
316
|
+
"steps": [
|
|
317
|
+
{"image": QUrl.fromLocalFile(str(path)).toString(),
|
|
318
|
+
"html": blocks[index] if index < len(blocks) else ""}
|
|
319
|
+
for index, path in enumerate(images)
|
|
320
|
+
],
|
|
321
|
+
})
|
|
322
|
+
return json.dumps(catalog, ensure_ascii=False)
|
|
323
|
+
|
|
324
|
+
@Slot(int, int, float, result=str)
|
|
325
|
+
def getReportPage(self, report_index, page_index, zoom):
|
|
326
|
+
return json.dumps(self._results.report_page(report_index, page_index, zoom))
|
|
327
|
+
|
|
328
|
+
@Slot(str, str, str, bool, int, result=str)
|
|
329
|
+
def getPredictionTable(self, key, query, sort_column, descending, page_index):
|
|
330
|
+
try:
|
|
331
|
+
result = self._results.prediction_table(key, query, sort_column, descending, page_index)
|
|
332
|
+
except (OSError, ValueError, KeyError, pd.errors.ParserError) as error:
|
|
333
|
+
result = {"error": f"Unable to load predictions: {error}"}
|
|
334
|
+
return json.dumps(result, ensure_ascii=False)
|
|
335
|
+
|
|
336
|
+
@Slot(str, str, result=str)
|
|
337
|
+
def getPredictionHistogram(self, key, column):
|
|
338
|
+
try:
|
|
339
|
+
result = self._results.prediction_histogram(key, column)
|
|
340
|
+
except (OSError, ValueError, KeyError, pd.errors.ParserError) as error:
|
|
341
|
+
result = {"error": f"Unable to load histogram: {error}"}
|
|
342
|
+
return json.dumps(result, ensure_ascii=False)
|
|
343
|
+
|
|
344
|
+
@Slot(str, result=str)
|
|
345
|
+
def getPredictionDiagnostics(self, key):
|
|
346
|
+
try:
|
|
347
|
+
result = self._results.prediction_diagnostics(key)
|
|
348
|
+
except (OSError, ValueError, KeyError) as error:
|
|
349
|
+
result = {"error": f"Unable to load diagnostics: {error}"}
|
|
350
|
+
return json.dumps(result, ensure_ascii=False)
|
|
351
|
+
|
|
352
|
+
@Slot(int, result=str)
|
|
353
|
+
def getPlotData(self, index):
|
|
354
|
+
try:
|
|
355
|
+
result = self._results.plot_data(index)
|
|
356
|
+
except (OSError, ValueError, KeyError, pd.errors.ParserError) as error:
|
|
357
|
+
result = {"error": f"Unable to load plot: {error}"}
|
|
358
|
+
return json.dumps(result, ensure_ascii=False)
|
|
359
|
+
|
|
360
|
+
@Slot(int, int, bool, result=str)
|
|
361
|
+
def getPlotMolecule(self, plot_index, row_index, williams):
|
|
362
|
+
return self._results.plot_molecule(plot_index, row_index, williams)
|
|
363
|
+
|
|
364
|
+
def _show_chemdraw_editor(self, molecules):
|
|
365
|
+
rows = []
|
|
366
|
+
for molecule in molecules:
|
|
367
|
+
smiles = Chem.MolToSmiles(molecule, canonical=False)
|
|
368
|
+
image = ""
|
|
369
|
+
try:
|
|
370
|
+
buffer = BytesIO()
|
|
371
|
+
Draw.MolToImage(molecule, size=(100, 100)).save(buffer, format="PNG")
|
|
372
|
+
image = "data:image/png;base64," + base64.b64encode(buffer.getvalue()).decode("ascii")
|
|
373
|
+
except (RuntimeError, ValueError):
|
|
374
|
+
pass
|
|
375
|
+
rows.append({"image": image, "SMILES": smiles, "code_name": "", "target": ""})
|
|
376
|
+
self._chemdraw_rows = rows
|
|
377
|
+
self.chemdrawReady.emit(json.dumps({"rows": rows}, ensure_ascii=False))
|
|
378
|
+
|
|
379
|
+
@Slot(str, result=str)
|
|
380
|
+
def saveChemdrawCsv(self, payload):
|
|
381
|
+
try:
|
|
382
|
+
document = json.loads(payload)
|
|
383
|
+
rows = document["rows"]
|
|
384
|
+
optional = document["columns"]
|
|
385
|
+
target_column = str(document["targetColumn"]).strip()
|
|
386
|
+
except (ValueError, KeyError, TypeError):
|
|
387
|
+
return json.dumps({"error": "Molecule table is invalid"})
|
|
388
|
+
allowed = ("charge", "mult", "complex_type", "sample", "geom")
|
|
389
|
+
if not isinstance(rows, list) or not rows or len(rows) != len(self._chemdraw_rows):
|
|
390
|
+
return json.dumps({"error": "Molecule rows do not match the imported file"})
|
|
391
|
+
if (not isinstance(optional, list) or any(not isinstance(name, str) for name in optional)
|
|
392
|
+
or len(set(optional)) != len(optional) or any(name not in allowed for name in optional)):
|
|
393
|
+
return json.dumps({"error": "Optional columns are invalid"})
|
|
394
|
+
if not target_column or target_column in {"SMILES", "code_name", *optional}:
|
|
395
|
+
return json.dumps({"error": "Choose a unique target column name"})
|
|
396
|
+
identifiers = []
|
|
397
|
+
normalized = []
|
|
398
|
+
complex_types = {"squareplanar", "squarepyramidal", "linear", "trigonalplanar"}
|
|
399
|
+
for row in rows:
|
|
400
|
+
if not isinstance(row, dict):
|
|
401
|
+
return json.dumps({"error": "Molecule row is invalid"})
|
|
402
|
+
smiles = str(row.get("SMILES", "")).strip()
|
|
403
|
+
identifier = str(row.get("code_name", "")).strip()
|
|
404
|
+
target = str(row.get("target", "")).strip()
|
|
405
|
+
if not smiles:
|
|
406
|
+
return json.dumps({"error": "Please fill in all SMILES fields"})
|
|
407
|
+
if not identifier:
|
|
408
|
+
return json.dumps({"error": "Please fill in all code_name fields"})
|
|
409
|
+
if not target:
|
|
410
|
+
return json.dumps({"error": "Target column is empty"})
|
|
411
|
+
try:
|
|
412
|
+
float(target)
|
|
413
|
+
except ValueError:
|
|
414
|
+
return json.dumps({"error": "Target column must be numeric"})
|
|
415
|
+
values = [smiles, identifier, target]
|
|
416
|
+
for name in optional:
|
|
417
|
+
value = str(row.get(name, "")).strip()
|
|
418
|
+
if name in {"charge", "mult", "sample"} and (not value or not value.lstrip("-").isdigit()):
|
|
419
|
+
return json.dumps({"error": f"Column {name} must be an integer"})
|
|
420
|
+
if name == "complex_type" and value not in complex_types:
|
|
421
|
+
return json.dumps({"error": "Select a complex_type for every molecule"})
|
|
422
|
+
if name == "geom" and not value:
|
|
423
|
+
return json.dumps({"error": "Column geom cannot be empty"})
|
|
424
|
+
values.append(value)
|
|
425
|
+
identifiers.append(identifier)
|
|
426
|
+
normalized.append(values)
|
|
427
|
+
if len(set(identifiers)) != len(identifiers):
|
|
428
|
+
return json.dumps({"error": "code_name values must be unique"})
|
|
429
|
+
path, _ = QFileDialog.getSaveFileName(self.window, "Save CSV", "", "CSV Files (*.csv)")
|
|
430
|
+
if not path:
|
|
431
|
+
return json.dumps({"cancelled": True})
|
|
432
|
+
if " " in Path(path).name:
|
|
433
|
+
return json.dumps({"error": "Choose a CSV filename without spaces so ROBERT can load it."})
|
|
434
|
+
try:
|
|
435
|
+
with open(path, "w", newline="", encoding="utf-8") as output:
|
|
436
|
+
writer = csv.writer(output)
|
|
437
|
+
writer.writerow(["SMILES", "code_name", target_column, *optional])
|
|
438
|
+
writer.writerows(normalized)
|
|
439
|
+
except OSError as error:
|
|
440
|
+
return json.dumps({"error": f"Unable to save CSV: {error}"})
|
|
441
|
+
if self.window.set_file_path(path) is False:
|
|
442
|
+
return json.dumps({"error": f"CSV was saved but could not be loaded: {path}"}, ensure_ascii=False)
|
|
443
|
+
return json.dumps({"saved": path}, ensure_ascii=False)
|
|
444
|
+
|
|
445
|
+
def push_state(self):
|
|
446
|
+
worker = getattr(self.window, "worker", None)
|
|
447
|
+
checkml_worker = getattr(self.window.checkml_tab, "worker", None)
|
|
448
|
+
running = any(
|
|
449
|
+
item is not None and item.isRunning()
|
|
450
|
+
for item in (worker, checkml_worker)
|
|
451
|
+
) or bool(getattr(self.window, "aqme_is_running", False))
|
|
452
|
+
interval = 400 if running else 1200
|
|
453
|
+
if self._timer.interval() != interval:
|
|
454
|
+
self._timer.setInterval(interval)
|
|
455
|
+
state = json.dumps(self._state(), ensure_ascii=False)
|
|
456
|
+
if state != self._last_state:
|
|
457
|
+
self._last_state = state
|
|
458
|
+
self.stateChanged.emit(state)
|
|
459
|
+
self._push_logs()
|
|
460
|
+
|
|
461
|
+
@Slot(str, str)
|
|
462
|
+
def setField(self, key, value):
|
|
463
|
+
if key.startswith("model."):
|
|
464
|
+
widget = self.window.options_tab.modellist.get(key[6:])
|
|
465
|
+
elif key.startswith("checkml_param."):
|
|
466
|
+
widget = self.window.checkml_tab.sklearn_param_fields.get(key[14:])
|
|
467
|
+
else:
|
|
468
|
+
widget = self._widget(key)
|
|
469
|
+
if widget is None or not widget.isEnabled():
|
|
470
|
+
return
|
|
471
|
+
if isinstance(widget, QComboBox):
|
|
472
|
+
index = widget.findText(value)
|
|
473
|
+
if index >= 0:
|
|
474
|
+
widget.setCurrentIndex(index)
|
|
475
|
+
elif isinstance(widget, QLineEdit):
|
|
476
|
+
widget.setText(value)
|
|
477
|
+
elif isinstance(widget, QCheckBox) or hasattr(widget, "setChecked"):
|
|
478
|
+
widget.setChecked(value == "true")
|
|
479
|
+
self.push_state()
|
|
480
|
+
|
|
481
|
+
@Slot(str)
|
|
482
|
+
def setBotDraft(self, value):
|
|
483
|
+
if self.window.app_mode == "checkml":
|
|
484
|
+
return
|
|
485
|
+
panel = self.window.bot_panel
|
|
486
|
+
if panel._busy:
|
|
487
|
+
return
|
|
488
|
+
if panel.input_edit.text() != value:
|
|
489
|
+
panel._selected_tutorial_id = ""
|
|
490
|
+
panel.input_edit.setText(value)
|
|
491
|
+
self.push_state()
|
|
492
|
+
|
|
493
|
+
@Slot(str)
|
|
494
|
+
def setBotApiKey(self, value):
|
|
495
|
+
if self.window.app_mode == "checkml":
|
|
496
|
+
return
|
|
497
|
+
panel = self.window.bot_panel
|
|
498
|
+
if panel.api_key_edit.isEnabled():
|
|
499
|
+
panel.api_key_edit.setText(value)
|
|
500
|
+
|
|
501
|
+
def _choose_file(self, title, file_filter, setter):
|
|
502
|
+
path, _ = QFileDialog.getOpenFileName(self.window, title, "", file_filter)
|
|
503
|
+
if path:
|
|
504
|
+
setter(path)
|
|
505
|
+
|
|
506
|
+
@Slot(str, str)
|
|
507
|
+
def performAction(self, action, value):
|
|
508
|
+
window = self.window
|
|
509
|
+
if window.app_mode == "checkml" and action in {
|
|
510
|
+
"botOpen", "botMode", "botProvider", "botWebSearch", "botSuggestion",
|
|
511
|
+
"botSend", "botClear", "botSaveApi", "botDeleteApi", "botResetUsage",
|
|
512
|
+
"botSummarize", "openBot", "openBotLink",
|
|
513
|
+
}:
|
|
514
|
+
return
|
|
515
|
+
checkml = window.checkml_tab
|
|
516
|
+
panel = window.bot_panel
|
|
517
|
+
if action == "activePage" and value in {
|
|
518
|
+
"workflow", "advanced", "aqme", "checkml", "results"
|
|
519
|
+
} and (window.app_mode != "checkml" or value in {"checkml", "results"}):
|
|
520
|
+
window.web_active_page = {
|
|
521
|
+
"workflow": "Workflow",
|
|
522
|
+
"advanced": "Advanced options",
|
|
523
|
+
"aqme": "AQME descriptors",
|
|
524
|
+
"checkml": "CheckML",
|
|
525
|
+
"results": "Results",
|
|
526
|
+
}[value]
|
|
527
|
+
if value != "results":
|
|
528
|
+
window.web_active_result_view = ""
|
|
529
|
+
elif action == "activeResultView" and value in {
|
|
530
|
+
"", "Report", "Predictions", "Images", "Interactive plots"
|
|
531
|
+
}:
|
|
532
|
+
window.web_active_result_view = value
|
|
533
|
+
elif action == "chooseTrain":
|
|
534
|
+
window.select_file()
|
|
535
|
+
elif action == "chooseTest":
|
|
536
|
+
window.select_csv_test_file()
|
|
537
|
+
elif action == "clearTest":
|
|
538
|
+
window.clear_test_file()
|
|
539
|
+
elif action == "chooseCheckmlTrain":
|
|
540
|
+
self._choose_file("Select CHECKML CSV", "CSV Files (*.csv)", checkml.set_csv_path)
|
|
541
|
+
elif action == "chooseCheckmlTest":
|
|
542
|
+
self._choose_file("Select external test CSV", "CSV Files (*.csv)", checkml.set_csv_test_path)
|
|
543
|
+
elif action == "clearCheckmlTest":
|
|
544
|
+
checkml.clear_csv_test_path()
|
|
545
|
+
elif action == "chooseCheckmlParams":
|
|
546
|
+
self._choose_file("Select model parameters", "CSV Files (*.csv)", checkml.set_model_params_path)
|
|
547
|
+
elif action == "chooseCheckmlModel":
|
|
548
|
+
self._choose_file("Select saved model", "Model files (*.joblib *.pkl *.pickle)", checkml.set_model_file_path)
|
|
549
|
+
elif action == "run" and window.run_button.isEnabled():
|
|
550
|
+
window.run_button.click()
|
|
551
|
+
elif action == "runAqme" and window.run_aqme_button.isEnabled():
|
|
552
|
+
window.run_aqme_button.click()
|
|
553
|
+
elif action == "stop" and window.stop_button.isEnabled():
|
|
554
|
+
window.stop_button.click()
|
|
555
|
+
elif action == "checkmlRun" and checkml.run_button.isEnabled():
|
|
556
|
+
checkml.run_button.click()
|
|
557
|
+
elif action == "checkmlStop" and checkml.stop_button.isEnabled():
|
|
558
|
+
checkml.stop_button.click()
|
|
559
|
+
elif action in {"ignore", "restore"}:
|
|
560
|
+
source = window.available_list if action == "ignore" else window.ignore_list
|
|
561
|
+
source.clearSelection()
|
|
562
|
+
for index in range(source.count()):
|
|
563
|
+
item = source.item(index)
|
|
564
|
+
if item.text() == value:
|
|
565
|
+
item.setSelected(True)
|
|
566
|
+
break
|
|
567
|
+
if action == "ignore":
|
|
568
|
+
window.move_to_selected()
|
|
569
|
+
else:
|
|
570
|
+
window.move_to_available()
|
|
571
|
+
elif action == "setResultModel":
|
|
572
|
+
selector = window.results_workspace.model_selector
|
|
573
|
+
index = selector.findData(value or None)
|
|
574
|
+
if index >= 0:
|
|
575
|
+
selector.setCurrentIndex(index)
|
|
576
|
+
elif action == "selectAtom":
|
|
577
|
+
try:
|
|
578
|
+
x, y = (int(float(position)) for position in value.split(",", 1))
|
|
579
|
+
except (ValueError, TypeError):
|
|
580
|
+
return
|
|
581
|
+
molecule = self._molecule_state()
|
|
582
|
+
if molecule["canSelect"] and 0 <= x < 400 and 0 <= y < 400:
|
|
583
|
+
atom = window.tab_widget_aqme.get_atom_at_position(x, y)
|
|
584
|
+
if atom is not None:
|
|
585
|
+
window.tab_widget_aqme.handle_atom_selection(atom)
|
|
586
|
+
elif action == "openChemdraw":
|
|
587
|
+
self._choose_file(
|
|
588
|
+
"Select ChemDraw or SDF file",
|
|
589
|
+
"ChemDraw Files (*.sdf *.cdxml *.mol *.cdx)",
|
|
590
|
+
lambda path: window.tab_widget_aqme.load_chemdraw_file(path, self._show_chemdraw_editor),
|
|
591
|
+
)
|
|
592
|
+
elif action == "imageAction":
|
|
593
|
+
image_id, separator, image_action = value.partition("|")
|
|
594
|
+
if separator and image_action in {"open", "copy", "save", "folder"}:
|
|
595
|
+
window.images_tab._bridge.performAction(image_id, image_action)
|
|
596
|
+
elif action == "botOpen":
|
|
597
|
+
window._ensure_bot_welcome_message()
|
|
598
|
+
elif action == "botMode":
|
|
599
|
+
if panel.mode_combo.isEnabled() and value in {panel.mode_combo.itemText(index) for index in range(panel.mode_combo.count())}:
|
|
600
|
+
panel.mode_combo.setCurrentText(value)
|
|
601
|
+
elif action == "botProvider":
|
|
602
|
+
if panel.provider_combo.isEnabled() and panel.provider_combo.findText(value) >= 0:
|
|
603
|
+
panel.provider_combo.setCurrentText(value)
|
|
604
|
+
elif action == "botWebSearch":
|
|
605
|
+
if panel.web_search_checkbox.isEnabled():
|
|
606
|
+
panel.web_search_checkbox.setChecked(value == "true")
|
|
607
|
+
elif action == "botSuggestion":
|
|
608
|
+
try:
|
|
609
|
+
index = int(value)
|
|
610
|
+
except ValueError:
|
|
611
|
+
return
|
|
612
|
+
if 0 < index < panel.suggested_combo.count():
|
|
613
|
+
panel.suggested_combo.setCurrentIndex(index)
|
|
614
|
+
elif action == "botSend" and panel.send_button.isEnabled():
|
|
615
|
+
panel.send_button.click()
|
|
616
|
+
elif action == "botClear":
|
|
617
|
+
window.clear_bot_history()
|
|
618
|
+
elif action == "botSaveApi" and panel.save_api_button.isEnabled():
|
|
619
|
+
panel.save_api_button.click()
|
|
620
|
+
elif action == "botDeleteApi" and panel.delete_api_button.isEnabled():
|
|
621
|
+
panel.delete_api_button.click()
|
|
622
|
+
elif action == "botResetUsage":
|
|
623
|
+
panel.reset_usage_button.click()
|
|
624
|
+
elif action == "botSummarize" and panel.workflow_summary_button.isEnabled():
|
|
625
|
+
panel.workflow_summary_button.click()
|
|
626
|
+
elif action == "openBotLink":
|
|
627
|
+
url = QUrl(value)
|
|
628
|
+
if url.isValid() and url.scheme().lower() in {"http", "https"} and url.host():
|
|
629
|
+
window.open_external_url(value)
|
|
630
|
+
elif action == "openMolssi":
|
|
631
|
+
window.show_molssi_workspace()
|
|
632
|
+
elif action == "molssiHome":
|
|
633
|
+
window.molssi_tab.web_view.setUrl(window.molssi_tab.databases_home_url)
|
|
634
|
+
elif action == "openHelp" and value in {"general", "curate", "generate", "predict"}:
|
|
635
|
+
window.options_tab.go_to_help_section(value)
|
|
636
|
+
elif action == "openHelp" and value == "aqme":
|
|
637
|
+
window.tab_widget_aqme.go_to_help_section("AQME")
|
|
638
|
+
elif action == "checkmlParamHelp" and checkml.model_source_dropdown.currentIndex() == 2:
|
|
639
|
+
checkml.model_params_info.click()
|
|
640
|
+
elif action == "openContact":
|
|
641
|
+
window.show_contact_dialog()
|
|
642
|
+
elif action == "openVersion":
|
|
643
|
+
window.show_version_dialog()
|
|
644
|
+
elif action == "openYouTube":
|
|
645
|
+
window.open_external_url("https://www.youtube.com/@thealegregroup4964/videos")
|
|
646
|
+
elif action == "openAlmos":
|
|
647
|
+
window.open_external_url("https://github.com/MiguelMartzFdez/almos")
|
|
648
|
+
elif action == "openClassic":
|
|
649
|
+
window.show_classic_panel(value)
|
|
650
|
+
elif action == "openResult" and value in {"Report", "Predictions", "Images", "Interactive plots"}:
|
|
651
|
+
if window.results_workspace._available.get(value):
|
|
652
|
+
window.show_result_view(value)
|
|
653
|
+
window.show_classic_panel("Results")
|
|
654
|
+
elif action == "openBot":
|
|
655
|
+
window.bot_toggle_btn.setChecked(True)
|
|
656
|
+
elif action == "openTutorial":
|
|
657
|
+
window.show_tutorial_dialog()
|
|
658
|
+
elif action == "openDocs":
|
|
659
|
+
window.open_external_url("https://robert.readthedocs.io/en/latest/")
|
|
660
|
+
elif action == "openGroqKeys":
|
|
661
|
+
window.open_external_url("https://console.groq.com/keys")
|
|
662
|
+
self.push_state()
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
class WebShell:
|
|
666
|
+
"""Attach the local web dashboard to an existing EasyROB window."""
|
|
667
|
+
|
|
668
|
+
def __init__(self, window):
|
|
669
|
+
from PySide6.QtWebChannel import QWebChannel
|
|
670
|
+
from PySide6.QtWebEngineWidgets import QWebEngineView
|
|
671
|
+
|
|
672
|
+
window.web_active_page = "CheckML" if window.app_mode == "checkml" else "Workflow"
|
|
673
|
+
window.web_active_result_view = ""
|
|
674
|
+
self.bridge = WorkflowBridge(window)
|
|
675
|
+
self.view = QWebEngineView(window)
|
|
676
|
+
self.channel = QWebChannel(self.view.page())
|
|
677
|
+
self.channel.registerObject("workflow", self.bridge)
|
|
678
|
+
self.view.page().setWebChannel(self.channel)
|
|
679
|
+
url = QUrl.fromLocalFile(str(Path(__file__).resolve().parent / "web" / "app.html"))
|
|
680
|
+
if window.app_mode == "checkml":
|
|
681
|
+
query = QUrlQuery()
|
|
682
|
+
query.addQueryItem("mode", "checkml")
|
|
683
|
+
url.setQuery(query)
|
|
684
|
+
self.view.setUrl(url)
|