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,447 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MolSSI databases tab for easyROB.
|
|
3
|
+
|
|
4
|
+
This module embeds the MolSSI descriptor database inside the GUI and provides
|
|
5
|
+
a complete download and post-processing pipeline.
|
|
6
|
+
|
|
7
|
+
Responsibilities:
|
|
8
|
+
- Host the MolSSI web interface (QWebEngineView)
|
|
9
|
+
- Intercept and manage file downloads
|
|
10
|
+
- Handle user-defined save locations
|
|
11
|
+
- Convert downloaded Excel files to CSV
|
|
12
|
+
- Integrate downloaded datasets into the easyROB workflow
|
|
13
|
+
|
|
14
|
+
Import strategy:
|
|
15
|
+
- Supports dual execution modes:
|
|
16
|
+
1. Local (portable execution)
|
|
17
|
+
2. Installed package (environment / entry point)
|
|
18
|
+
|
|
19
|
+
- Imports use a try/except fallback for compatibility.
|
|
20
|
+
|
|
21
|
+
Notes:
|
|
22
|
+
- Combines UI interaction (web view) with background processing (workers).
|
|
23
|
+
- Designed to keep the main window decoupled from download logic.
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
try:
|
|
27
|
+
from utils.utils_gui import (
|
|
28
|
+
Path,
|
|
29
|
+
QFileDialog,
|
|
30
|
+
QHBoxLayout,
|
|
31
|
+
QMessageBox,
|
|
32
|
+
QPushButton,
|
|
33
|
+
QSizePolicy,
|
|
34
|
+
QTimer,
|
|
35
|
+
QUrl,
|
|
36
|
+
QVBoxLayout,
|
|
37
|
+
QWebEngineDownloadRequest,
|
|
38
|
+
QWebEngineView,
|
|
39
|
+
QWidget,
|
|
40
|
+
Qt,
|
|
41
|
+
Signal,
|
|
42
|
+
)
|
|
43
|
+
from utils.molssi_utils import ExcelToCSVWorker, validate_molssi_test_csv
|
|
44
|
+
|
|
45
|
+
except ImportError as e:
|
|
46
|
+
from robert.gui_easyrob.utils.utils_gui import (
|
|
47
|
+
Path,
|
|
48
|
+
QFileDialog,
|
|
49
|
+
QHBoxLayout,
|
|
50
|
+
QMessageBox,
|
|
51
|
+
QPushButton,
|
|
52
|
+
QSizePolicy,
|
|
53
|
+
QTimer,
|
|
54
|
+
QUrl,
|
|
55
|
+
QVBoxLayout,
|
|
56
|
+
QWebEngineDownloadRequest,
|
|
57
|
+
QWebEngineView,
|
|
58
|
+
QWidget,
|
|
59
|
+
Qt,
|
|
60
|
+
Signal,
|
|
61
|
+
)
|
|
62
|
+
from robert.gui_easyrob.utils.molssi_utils import ExcelToCSVWorker, validate_molssi_test_csv
|
|
63
|
+
|
|
64
|
+
# ---- Standard library ----
|
|
65
|
+
import os
|
|
66
|
+
|
|
67
|
+
class MolSSIDatabasesTab(QWidget):
|
|
68
|
+
"""
|
|
69
|
+
Tab widget embedding the MolSSI descriptor databases web interface.
|
|
70
|
+
|
|
71
|
+
This widget:
|
|
72
|
+
- Hosts a QWebEngineView pointing to the MolSSI databases site
|
|
73
|
+
- Intercepts downloads initiated from the web view
|
|
74
|
+
- Allows saving descriptor files locally
|
|
75
|
+
- Optionally converts downloaded Excel files to CSV
|
|
76
|
+
"""
|
|
77
|
+
# Signal emitted when a test file download is requested
|
|
78
|
+
load_test_requested = Signal(str)
|
|
79
|
+
|
|
80
|
+
def __init__(self, parent=None):
|
|
81
|
+
super().__init__(parent)
|
|
82
|
+
|
|
83
|
+
# Context used to determine post-download behaviour
|
|
84
|
+
self.current_download_context = "active"
|
|
85
|
+
|
|
86
|
+
# Worker used for Excel -> CSV conversion
|
|
87
|
+
self._excel_worker = None
|
|
88
|
+
|
|
89
|
+
# State used during downloads
|
|
90
|
+
self._pending_popup = None
|
|
91
|
+
self._pending_path = None
|
|
92
|
+
|
|
93
|
+
layout = QVBoxLayout(self)
|
|
94
|
+
|
|
95
|
+
# --------------------------------------------------
|
|
96
|
+
# WebView subclass: force single-window navigation
|
|
97
|
+
# --------------------------------------------------
|
|
98
|
+
class SingleWindowWebView(QWebEngineView):
|
|
99
|
+
"""
|
|
100
|
+
Custom QWebEngineView that prevents opening external windows.
|
|
101
|
+
Any request to open a new window is redirected to the same view.
|
|
102
|
+
"""
|
|
103
|
+
def createWindow(self, webWindowType):
|
|
104
|
+
tmp = QWebEngineView(self)
|
|
105
|
+
tmp.setAttribute(Qt.WA_DeleteOnClose, True)
|
|
106
|
+
tmp.urlChanged.connect(
|
|
107
|
+
lambda url: (self.setUrl(url), tmp.deleteLater())
|
|
108
|
+
)
|
|
109
|
+
return tmp
|
|
110
|
+
|
|
111
|
+
# Base URL for MolSSI databases
|
|
112
|
+
self.databases_home_url = QUrl(
|
|
113
|
+
"https://descriptor-libraries.molssi.org/"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# --------------------------------------------------
|
|
117
|
+
# Home bar
|
|
118
|
+
# --------------------------------------------------
|
|
119
|
+
home_bar = QWidget()
|
|
120
|
+
home_bar.setContentsMargins(0, 0, 0, 0)
|
|
121
|
+
home_bar.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
|
122
|
+
|
|
123
|
+
home_layout = QHBoxLayout(home_bar)
|
|
124
|
+
home_layout.setContentsMargins(0, 0, 0, 0)
|
|
125
|
+
home_layout.setSpacing(2)
|
|
126
|
+
|
|
127
|
+
home_button = QPushButton("🏠 MolSSI Databases")
|
|
128
|
+
home_button.setToolTip("Return to the Databases start page")
|
|
129
|
+
home_button.setCursor(Qt.PointingHandCursor)
|
|
130
|
+
home_button.setFixedSize(150, 24)
|
|
131
|
+
home_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
|
132
|
+
home_button.clicked.connect(
|
|
133
|
+
lambda: self.web_view.setUrl(self.databases_home_url)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
home_layout.addWidget(home_button)
|
|
137
|
+
home_layout.addStretch()
|
|
138
|
+
|
|
139
|
+
layout.addWidget(home_bar, 0, Qt.AlignLeft)
|
|
140
|
+
|
|
141
|
+
# --------------------------------------------------
|
|
142
|
+
# Web view
|
|
143
|
+
# --------------------------------------------------
|
|
144
|
+
self.web_view = SingleWindowWebView()
|
|
145
|
+
self.web_view.setUrl(self.databases_home_url)
|
|
146
|
+
layout.addWidget(self.web_view, 1)
|
|
147
|
+
|
|
148
|
+
# --------------------------------------------------
|
|
149
|
+
# Download handling
|
|
150
|
+
# --------------------------------------------------
|
|
151
|
+
profile = self.web_view.page().profile()
|
|
152
|
+
profile.downloadRequested.connect(self._handle_download)
|
|
153
|
+
|
|
154
|
+
# ==================================================
|
|
155
|
+
# PUBLIC API
|
|
156
|
+
# ==================================================
|
|
157
|
+
def handle_external_download(self, path, context="active", expected_columns=None):
|
|
158
|
+
"""
|
|
159
|
+
Entry point used by EasyROB when a file has already been downloaded
|
|
160
|
+
externally and should follow the same post-download pipeline.
|
|
161
|
+
"""
|
|
162
|
+
self.current_download_context = context
|
|
163
|
+
self._on_download_completed(path, expected_columns=expected_columns)
|
|
164
|
+
|
|
165
|
+
# ==================================================
|
|
166
|
+
# DOWNLOAD HANDLING
|
|
167
|
+
# ==================================================
|
|
168
|
+
def _handle_download(self, req: QWebEngineDownloadRequest):
|
|
169
|
+
"""
|
|
170
|
+
Intercepts download requests coming from the embedded web view.
|
|
171
|
+
Prompts the user for a save location and tracks download completion.
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
def open_dialog():
|
|
175
|
+
suggested = (
|
|
176
|
+
req.downloadFileName()
|
|
177
|
+
or QUrl(req.url()).fileName()
|
|
178
|
+
or "download"
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
path, _ = QFileDialog.getSaveFileName(
|
|
182
|
+
self,
|
|
183
|
+
"Save File",
|
|
184
|
+
suggested
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
if not path:
|
|
188
|
+
req.cancel()
|
|
189
|
+
return
|
|
190
|
+
|
|
191
|
+
req.setDownloadDirectory(os.path.dirname(path))
|
|
192
|
+
req.setDownloadFileName(os.path.basename(path))
|
|
193
|
+
req.accept()
|
|
194
|
+
|
|
195
|
+
self._pending_path = path
|
|
196
|
+
self._pending_popup = self._show_download_popup()
|
|
197
|
+
|
|
198
|
+
req.stateChanged.connect(self._on_download_state_changed)
|
|
199
|
+
|
|
200
|
+
# Ensure dialog is opened outside the WebEngine callback stack
|
|
201
|
+
QTimer.singleShot(0, open_dialog)
|
|
202
|
+
|
|
203
|
+
def _on_download_state_changed(self, state):
|
|
204
|
+
"""
|
|
205
|
+
Reacts to state changes of a QWebEngine download.
|
|
206
|
+
When completed, triggers the post-download pipeline.
|
|
207
|
+
"""
|
|
208
|
+
if state == QWebEngineDownloadRequest.DownloadCompleted:
|
|
209
|
+
if self._pending_popup:
|
|
210
|
+
self._pending_popup.close()
|
|
211
|
+
self._pending_popup.deleteLater()
|
|
212
|
+
self._pending_popup = None
|
|
213
|
+
|
|
214
|
+
if self._pending_path:
|
|
215
|
+
self._on_download_completed(self._pending_path)
|
|
216
|
+
self._pending_path = None
|
|
217
|
+
|
|
218
|
+
# ==================================================
|
|
219
|
+
# POST-DOWNLOAD PIPELINE
|
|
220
|
+
# ==================================================
|
|
221
|
+
def _on_download_completed(self, path, expected_columns=None):
|
|
222
|
+
"""
|
|
223
|
+
Called once a file has been fully downloaded.
|
|
224
|
+
Handles user confirmation and optional Excel-to-CSV conversion.
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
# Consume context and reset to default
|
|
228
|
+
ctx = self.current_download_context
|
|
229
|
+
self.current_download_context = "active"
|
|
230
|
+
|
|
231
|
+
if ctx != "molssi_test":
|
|
232
|
+
prompt = (
|
|
233
|
+
"The Excel file has been downloaded successfully.\n\n"
|
|
234
|
+
"This file contains chemical descriptors and molecular identifiers.\n"
|
|
235
|
+
"Converting it to CSV will create a simpler, universal file format that can be loaded in easyROB later.\n\n"
|
|
236
|
+
"Note: If you plan to build predictive models, you will need to include a target "
|
|
237
|
+
"(for example, an experimental property or value you want to predict).\n\n"
|
|
238
|
+
"Do you want to convert this Excel file to CSV now?"
|
|
239
|
+
)
|
|
240
|
+
msg = QMessageBox(self)
|
|
241
|
+
msg.setIcon(QMessageBox.Question)
|
|
242
|
+
msg.setWindowTitle("Convert Excel to CSV")
|
|
243
|
+
msg.setText(prompt)
|
|
244
|
+
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
|
|
245
|
+
msg.setDefaultButton(QMessageBox.Yes)
|
|
246
|
+
reply = self._exec_tracked_message_box(
|
|
247
|
+
msg,
|
|
248
|
+
title="Convert Excel to CSV",
|
|
249
|
+
text=prompt,
|
|
250
|
+
buttons=["Yes", "No"],
|
|
251
|
+
kind="question",
|
|
252
|
+
source="molssi_conversion_prompt",
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
if reply != QMessageBox.Yes:
|
|
256
|
+
return
|
|
257
|
+
|
|
258
|
+
self._convert_excel(path, ctx, expected_columns)
|
|
259
|
+
|
|
260
|
+
# ==================================================
|
|
261
|
+
# CONVERSION WORKER
|
|
262
|
+
# ==================================================
|
|
263
|
+
def _convert_excel(self, path, ctx, expected_columns=None):
|
|
264
|
+
"""
|
|
265
|
+
Launches a background worker that converts an Excel file to CSV.
|
|
266
|
+
Displays a non-blocking progress popup during conversion.
|
|
267
|
+
"""
|
|
268
|
+
popup = QMessageBox(self)
|
|
269
|
+
popup.setWindowTitle("Converting file")
|
|
270
|
+
popup.setText("Converting Excel to CSV…\n\nPlease wait.")
|
|
271
|
+
popup.setStandardButtons(QMessageBox.NoButton)
|
|
272
|
+
popup.setModal(False)
|
|
273
|
+
main_window = self.window()
|
|
274
|
+
popup_state = None
|
|
275
|
+
if hasattr(main_window, "_track_open_popup"):
|
|
276
|
+
popup_state = main_window._track_open_popup(
|
|
277
|
+
title="Converting file",
|
|
278
|
+
text="Converting Excel to CSV…\n\nPlease wait.",
|
|
279
|
+
buttons=[],
|
|
280
|
+
kind="info",
|
|
281
|
+
source="molssi_conversion_progress",
|
|
282
|
+
)
|
|
283
|
+
popup.show()
|
|
284
|
+
|
|
285
|
+
worker = ExcelToCSVWorker(path)
|
|
286
|
+
self._excel_worker = worker
|
|
287
|
+
|
|
288
|
+
def finished(csv_path):
|
|
289
|
+
if getattr(main_window, "molssi_is_closing", False):
|
|
290
|
+
if hasattr(main_window, "_clear_active_popup"):
|
|
291
|
+
main_window._clear_active_popup(popup_state)
|
|
292
|
+
popup.close()
|
|
293
|
+
popup.deleteLater()
|
|
294
|
+
return
|
|
295
|
+
if ctx == "molssi_test":
|
|
296
|
+
try:
|
|
297
|
+
validate_molssi_test_csv(csv_path, expected_columns or [])
|
|
298
|
+
except (OSError, ValueError) as exc:
|
|
299
|
+
error(str(exc))
|
|
300
|
+
return
|
|
301
|
+
if hasattr(main_window, "_clear_active_popup"):
|
|
302
|
+
main_window._clear_active_popup(popup_state)
|
|
303
|
+
popup.close()
|
|
304
|
+
popup.deleteLater()
|
|
305
|
+
|
|
306
|
+
if ctx == "molssi_test":
|
|
307
|
+
self.load_test_molssi(csv_path, source=path)
|
|
308
|
+
return
|
|
309
|
+
|
|
310
|
+
msg = QMessageBox(self)
|
|
311
|
+
msg.setIcon(QMessageBox.Information)
|
|
312
|
+
msg.setWindowTitle("Conversion completed")
|
|
313
|
+
msg.setText("Excel converted to CSV successfully.")
|
|
314
|
+
msg.setStandardButtons(QMessageBox.Ok)
|
|
315
|
+
self._exec_tracked_message_box(
|
|
316
|
+
msg,
|
|
317
|
+
title="Conversion completed",
|
|
318
|
+
text="Excel converted to CSV successfully.",
|
|
319
|
+
buttons=["OK"],
|
|
320
|
+
kind="info",
|
|
321
|
+
source="molssi_conversion_completed",
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
def error(msg):
|
|
325
|
+
if hasattr(main_window, "_clear_active_popup"):
|
|
326
|
+
main_window._clear_active_popup(popup_state)
|
|
327
|
+
popup.close()
|
|
328
|
+
popup.deleteLater()
|
|
329
|
+
if getattr(main_window, "molssi_is_closing", False):
|
|
330
|
+
return
|
|
331
|
+
warning = QMessageBox(self)
|
|
332
|
+
warning.setIcon(QMessageBox.Warning)
|
|
333
|
+
warning.setWindowTitle("Conversion failed")
|
|
334
|
+
warning.setText(msg)
|
|
335
|
+
warning.setStandardButtons(QMessageBox.Ok)
|
|
336
|
+
self._exec_tracked_message_box(
|
|
337
|
+
warning,
|
|
338
|
+
title="Conversion failed",
|
|
339
|
+
text=msg,
|
|
340
|
+
buttons=["OK"],
|
|
341
|
+
kind="warning",
|
|
342
|
+
source="molssi_conversion",
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
worker.finished.connect(finished)
|
|
346
|
+
worker.error.connect(error)
|
|
347
|
+
worker.start()
|
|
348
|
+
|
|
349
|
+
# ==================================================
|
|
350
|
+
# UI HELPERS
|
|
351
|
+
# ==================================================
|
|
352
|
+
def _show_download_popup(self):
|
|
353
|
+
"""
|
|
354
|
+
Displays a non-modal popup informing the user that a download
|
|
355
|
+
is in progress and continues in the background.
|
|
356
|
+
"""
|
|
357
|
+
popup = QMessageBox(self)
|
|
358
|
+
popup.setWindowTitle("Downloading file")
|
|
359
|
+
popup.setText(
|
|
360
|
+
"Downloading file…\n\n"
|
|
361
|
+
"You can close this window.\n"
|
|
362
|
+
"The download will continue in the background."
|
|
363
|
+
)
|
|
364
|
+
popup.setStandardButtons(QMessageBox.Ok)
|
|
365
|
+
popup.setModal(False)
|
|
366
|
+
main_window = self.window()
|
|
367
|
+
popup_state = None
|
|
368
|
+
if hasattr(main_window, "_track_open_popup"):
|
|
369
|
+
popup_state = main_window._track_open_popup(
|
|
370
|
+
title="Downloading file",
|
|
371
|
+
text=(
|
|
372
|
+
"Downloading file…\n\n"
|
|
373
|
+
"You can close this window.\n"
|
|
374
|
+
"The download will continue in the background."
|
|
375
|
+
),
|
|
376
|
+
buttons=["OK"],
|
|
377
|
+
kind="info",
|
|
378
|
+
source="molssi_download",
|
|
379
|
+
)
|
|
380
|
+
popup.destroyed.connect(lambda *_: main_window._clear_active_popup(popup_state))
|
|
381
|
+
popup.show()
|
|
382
|
+
return popup
|
|
383
|
+
|
|
384
|
+
def _exec_tracked_message_box(
|
|
385
|
+
self,
|
|
386
|
+
message_box,
|
|
387
|
+
*,
|
|
388
|
+
title: str,
|
|
389
|
+
text: str,
|
|
390
|
+
buttons: list[str] | None = None,
|
|
391
|
+
kind: str = "",
|
|
392
|
+
source: str = "",
|
|
393
|
+
):
|
|
394
|
+
main_window = self.window()
|
|
395
|
+
if hasattr(main_window, "_exec_tracked_message_box"):
|
|
396
|
+
return main_window._exec_tracked_message_box(
|
|
397
|
+
message_box,
|
|
398
|
+
title=title,
|
|
399
|
+
text=text,
|
|
400
|
+
buttons=buttons,
|
|
401
|
+
kind=kind,
|
|
402
|
+
source=source,
|
|
403
|
+
)
|
|
404
|
+
return message_box.exec()
|
|
405
|
+
|
|
406
|
+
def load_test_molssi(self, csv_path, source=None):
|
|
407
|
+
"""
|
|
408
|
+
Finalizes a MolSSI test dataset.
|
|
409
|
+
"""
|
|
410
|
+
|
|
411
|
+
# Ask main window to load this CSV as TEST
|
|
412
|
+
self.load_test_requested.emit(csv_path)
|
|
413
|
+
if getattr(self.window(), "csv_test_path", None) != csv_path:
|
|
414
|
+
return False
|
|
415
|
+
|
|
416
|
+
# -------------------------------------------------
|
|
417
|
+
# Inform user
|
|
418
|
+
# -------------------------------------------------
|
|
419
|
+
msg = QMessageBox(self)
|
|
420
|
+
msg.setIcon(QMessageBox.Information)
|
|
421
|
+
msg.setWindowTitle("MolSSI test dataset loaded")
|
|
422
|
+
msg.setText(
|
|
423
|
+
"The MolSSI database was converted to CSV and loaded as an external test set.\n\n"
|
|
424
|
+
f"CSV: {csv_path}"
|
|
425
|
+
)
|
|
426
|
+
msg.setStandardButtons(QMessageBox.Ok)
|
|
427
|
+
self._exec_tracked_message_box(
|
|
428
|
+
msg,
|
|
429
|
+
title="MolSSI test dataset loaded",
|
|
430
|
+
text=(
|
|
431
|
+
"The MolSSI database was converted to CSV and loaded as an external test set.\n\n"
|
|
432
|
+
f"CSV: {csv_path}"
|
|
433
|
+
),
|
|
434
|
+
buttons=["OK"],
|
|
435
|
+
kind="info",
|
|
436
|
+
source="molssi_test_dataset_loaded",
|
|
437
|
+
)
|
|
438
|
+
|
|
439
|
+
# -------------------
|
|
440
|
+
# Cleanup raw Excel
|
|
441
|
+
# -------------------
|
|
442
|
+
if source:
|
|
443
|
+
try:
|
|
444
|
+
Path(source).unlink()
|
|
445
|
+
except Exception:
|
|
446
|
+
pass
|
|
447
|
+
return True
|