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,33 @@
|
|
|
1
|
+
"""Layout regression checks for styled multi-action message boxes."""
|
|
2
|
+
|
|
3
|
+
from PySide6.QtWidgets import QApplication, QDialogButtonBox, QMessageBox
|
|
4
|
+
|
|
5
|
+
from gui_easyrob.web_dialogs import style_dialog
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_descriptor_choices_keep_full_button_labels():
|
|
9
|
+
app = QApplication.instance() or QApplication([])
|
|
10
|
+
dialog = QMessageBox()
|
|
11
|
+
dialog.setWindowTitle("AQME completed successfully")
|
|
12
|
+
dialog.setText("Select a file to load into ROBERT, or cancel to continue.")
|
|
13
|
+
labels = (
|
|
14
|
+
"Interpret descriptors (recommended)",
|
|
15
|
+
"DeNovo descriptors",
|
|
16
|
+
"Full descriptors",
|
|
17
|
+
"Cancel",
|
|
18
|
+
)
|
|
19
|
+
for label in labels:
|
|
20
|
+
dialog.addButton(label, QMessageBox.ActionRole)
|
|
21
|
+
style_dialog(dialog)
|
|
22
|
+
dialog.show()
|
|
23
|
+
app.processEvents()
|
|
24
|
+
try:
|
|
25
|
+
button_box = dialog.findChild(QDialogButtonBox)
|
|
26
|
+
assert button_box is not None
|
|
27
|
+
for button in button_box.buttons():
|
|
28
|
+
required = button.fontMetrics().horizontalAdvance(button.text()) + 32
|
|
29
|
+
assert button.width() >= required, (button.text(), button.width(), required)
|
|
30
|
+
assert dialog.rect().contains(button.mapTo(dialog, button.rect().topLeft()))
|
|
31
|
+
assert dialog.rect().contains(button.mapTo(dialog, button.rect().bottomRight()))
|
|
32
|
+
finally:
|
|
33
|
+
dialog.close()
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"""Regression tests for workflow execution and robBOT lifecycle behavior."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from types import SimpleNamespace
|
|
5
|
+
import os
|
|
6
|
+
import shlex
|
|
7
|
+
import sys
|
|
8
|
+
import tempfile
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
|
12
|
+
from PySide6.QtCore import QSettings
|
|
13
|
+
from PySide6.QtWidgets import QApplication
|
|
14
|
+
|
|
15
|
+
from gui_easyrob.bot.bot_context import GuiSnapshot
|
|
16
|
+
from gui_easyrob.bot.bot_engine import BotEngine
|
|
17
|
+
from gui_easyrob.bot.bot_rag import KnowledgeBase
|
|
18
|
+
from gui_easyrob.bot.bot_panel import BotPanel
|
|
19
|
+
from gui_easyrob.main.window import EasyROB
|
|
20
|
+
from gui_easyrob.utils.utils_gui import RobertWorker
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class _Choice:
|
|
24
|
+
def __init__(self, text):
|
|
25
|
+
self.text = text
|
|
26
|
+
|
|
27
|
+
def currentText(self):
|
|
28
|
+
return self.text
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_robbot_exposes_only_cloud_and_heuristic_modes():
|
|
32
|
+
app = QApplication.instance() or QApplication([])
|
|
33
|
+
panel = BotPanel()
|
|
34
|
+
try:
|
|
35
|
+
modes = [panel.mode_combo.itemText(index) for index in range(panel.mode_combo.count())]
|
|
36
|
+
assert modes == ["Cloud AI", "Heuristic"]
|
|
37
|
+
assert panel.mode_combo.currentText() == "Cloud AI"
|
|
38
|
+
finally:
|
|
39
|
+
panel.close()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_retired_local_mode_is_rejected_by_engine():
|
|
43
|
+
engine = BotEngine(knowledge_base=KnowledgeBase.from_records([]))
|
|
44
|
+
snapshot = GuiSnapshot(
|
|
45
|
+
active_tab="ROBERT",
|
|
46
|
+
workflow="Full Workflow",
|
|
47
|
+
main_csv_path="",
|
|
48
|
+
test_csv_path="",
|
|
49
|
+
target_column="",
|
|
50
|
+
prediction_type="Regression",
|
|
51
|
+
process_running=False,
|
|
52
|
+
run_enabled=False,
|
|
53
|
+
stop_enabled=False,
|
|
54
|
+
recent_console="",
|
|
55
|
+
console_terms=[],
|
|
56
|
+
)
|
|
57
|
+
answer = engine.answer("Hello", snapshot, "Local AI", "Groq", "")
|
|
58
|
+
assert answer == "Unsupported bot mode."
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class _Toggle:
|
|
62
|
+
def __init__(self, checked):
|
|
63
|
+
self.checked = checked
|
|
64
|
+
|
|
65
|
+
def isChecked(self):
|
|
66
|
+
return self.checked
|
|
67
|
+
|
|
68
|
+
def setChecked(self, value):
|
|
69
|
+
self.checked = value
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class _TextField:
|
|
73
|
+
def __init__(self, value=""):
|
|
74
|
+
self.value = value
|
|
75
|
+
|
|
76
|
+
def text(self):
|
|
77
|
+
return self.value
|
|
78
|
+
|
|
79
|
+
def setText(self, value):
|
|
80
|
+
self.value = value
|
|
81
|
+
|
|
82
|
+
def clear(self):
|
|
83
|
+
self.value = ""
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class _SettingsPanel:
|
|
87
|
+
def __init__(self, api_key=""):
|
|
88
|
+
self.api_key_edit = _TextField(api_key)
|
|
89
|
+
self.provider_combo = _Choice("Groq")
|
|
90
|
+
self.provider_combo.findText = lambda value: 0 if value == "Groq" else -1
|
|
91
|
+
self.provider_combo.setCurrentIndex = lambda index: None
|
|
92
|
+
self.mode_combo = _Choice("Cloud AI")
|
|
93
|
+
self.mode_combo.setCurrentText = lambda value: None
|
|
94
|
+
self.web_search_checkbox = _Toggle(True)
|
|
95
|
+
self.saved = False
|
|
96
|
+
|
|
97
|
+
def set_saved_api_state(self, saved):
|
|
98
|
+
self.saved = saved
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class _CommandState:
|
|
102
|
+
def __init__(self, workflow="Full Workflow"):
|
|
103
|
+
self.workflow_selector = _Choice(workflow)
|
|
104
|
+
self.all_models_toggle = _Toggle(False)
|
|
105
|
+
self.y_dropdown = _Choice("target")
|
|
106
|
+
self.names_dropdown = _Choice("name")
|
|
107
|
+
self.type_dropdown = _Choice("Regression")
|
|
108
|
+
self.ignore_list = SimpleNamespace(count=lambda: 0)
|
|
109
|
+
self.aqme_workflow = _Toggle(False)
|
|
110
|
+
self.tab_widget_aqme = SimpleNamespace(selected_atoms=[])
|
|
111
|
+
self.csv_test_path = ""
|
|
112
|
+
self.auto_type_value = True
|
|
113
|
+
self.split_value = "even"
|
|
114
|
+
self.categorical_value = "onehot"
|
|
115
|
+
self.corr_filter_x_value = True
|
|
116
|
+
self.corr_filter_y_value = False
|
|
117
|
+
self.rfecv_filter_value = True
|
|
118
|
+
self.pfi_filter_value = True
|
|
119
|
+
self.auto_test_value = True
|
|
120
|
+
|
|
121
|
+
def _resolve_python_executable(self):
|
|
122
|
+
return "python"
|
|
123
|
+
|
|
124
|
+
def __getattr__(self, name):
|
|
125
|
+
return 0
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_qdescp_atoms_and_solvent_are_passed_together():
|
|
129
|
+
state = _CommandState()
|
|
130
|
+
state.aqme_workflow = _Toggle(True)
|
|
131
|
+
state.tab_widget_aqme.selected_atoms = [object()]
|
|
132
|
+
state.descriptor_level_selected = "interpret"
|
|
133
|
+
state.atoms_selected = ""
|
|
134
|
+
state.solvent_selected = "water"
|
|
135
|
+
|
|
136
|
+
command = EasyROB.build_robert_command(state, "train.csv")
|
|
137
|
+
arguments = shlex.split(command)
|
|
138
|
+
keyword_values = [
|
|
139
|
+
arguments[index + 1]
|
|
140
|
+
for index, value in enumerate(arguments[:-1])
|
|
141
|
+
if value == "--qdescp_keywords"
|
|
142
|
+
]
|
|
143
|
+
assert keyword_values == ["--qdescp_atoms [1] --qdescp_solvent water"]
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def test_external_test_csv_keeps_its_absolute_path(tmp_path):
|
|
147
|
+
state = _CommandState(workflow="PREDICT")
|
|
148
|
+
test_path = tmp_path / "external" / "test.csv"
|
|
149
|
+
state.csv_test_path = str(test_path)
|
|
150
|
+
|
|
151
|
+
command = EasyROB.build_robert_command(state, str(tmp_path / "train" / "train.csv"))
|
|
152
|
+
arguments = shlex.split(command)
|
|
153
|
+
assert arguments[arguments.index("--csv_test") + 1] == str(test_path)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def test_worker_reports_process_start_failure_as_finished():
|
|
157
|
+
worker = RobertWorker("missing_easyrob_executable_234981")
|
|
158
|
+
errors = []
|
|
159
|
+
exit_codes = []
|
|
160
|
+
worker.error_received.connect(errors.append)
|
|
161
|
+
worker.process_finished.connect(exit_codes.append)
|
|
162
|
+
|
|
163
|
+
worker.run()
|
|
164
|
+
|
|
165
|
+
assert errors
|
|
166
|
+
assert exit_codes == [1]
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_clearing_chat_discards_history():
|
|
170
|
+
class Input:
|
|
171
|
+
def clear(self):
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
def setFocus(self, *_):
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
panel = SimpleNamespace(input_edit=Input(), clear_history=lambda: None)
|
|
178
|
+
state = SimpleNamespace(
|
|
179
|
+
_bot_conversation_generation=0,
|
|
180
|
+
bot_worker=None,
|
|
181
|
+
bot_history=[{"role": "user", "content": "old question"}],
|
|
182
|
+
bot_panel=panel,
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
EasyROB.clear_bot_history(state)
|
|
186
|
+
|
|
187
|
+
assert state.bot_history == []
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@pytest.mark.skipif(sys.platform != "win32", reason="Windows DPAPI regression")
|
|
191
|
+
def test_saved_api_key_is_protected_and_can_be_deleted():
|
|
192
|
+
from gui_easyrob.bot.credential_store import CredentialStore
|
|
193
|
+
|
|
194
|
+
with tempfile.TemporaryDirectory(dir=Path(__file__).parent) as temp_dir:
|
|
195
|
+
settings_path = Path(temp_dir) / "settings.ini"
|
|
196
|
+
settings = QSettings(str(settings_path), QSettings.IniFormat)
|
|
197
|
+
store = CredentialStore(settings)
|
|
198
|
+
|
|
199
|
+
store.save("example-secret-key")
|
|
200
|
+
settings.sync()
|
|
201
|
+
|
|
202
|
+
assert settings.value("bot/api_key") is None
|
|
203
|
+
assert "example-secret-key" not in settings_path.read_text(encoding="utf-8")
|
|
204
|
+
assert store.load() == "example-secret-key"
|
|
205
|
+
|
|
206
|
+
store.delete()
|
|
207
|
+
assert store.load() == ""
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def test_non_windows_api_key_uses_system_keyring(monkeypatch):
|
|
211
|
+
from gui_easyrob.bot import credential_store
|
|
212
|
+
|
|
213
|
+
saved = {}
|
|
214
|
+
keyring = SimpleNamespace(
|
|
215
|
+
set_password=lambda service, account, secret: saved.__setitem__((service, account), secret),
|
|
216
|
+
get_password=lambda service, account: saved.get((service, account)),
|
|
217
|
+
delete_password=lambda service, account: saved.pop((service, account)),
|
|
218
|
+
)
|
|
219
|
+
monkeypatch.setattr(credential_store.sys, "platform", "linux")
|
|
220
|
+
monkeypatch.setattr(credential_store.CredentialStore, "_keyring", staticmethod(lambda: keyring))
|
|
221
|
+
|
|
222
|
+
with tempfile.TemporaryDirectory(dir=Path(__file__).parent) as temp_dir:
|
|
223
|
+
settings_path = Path(temp_dir) / "settings.ini"
|
|
224
|
+
settings = QSettings(str(settings_path), QSettings.IniFormat)
|
|
225
|
+
store = credential_store.CredentialStore(settings)
|
|
226
|
+
|
|
227
|
+
store.save("example-secret-key")
|
|
228
|
+
assert store.load() == "example-secret-key"
|
|
229
|
+
assert settings.value("bot/api_key") is None
|
|
230
|
+
assert settings.value("bot/api_key_protected") is None
|
|
231
|
+
if settings_path.exists():
|
|
232
|
+
assert "example-secret-key" not in settings_path.read_text(encoding="utf-8")
|
|
233
|
+
|
|
234
|
+
store.delete()
|
|
235
|
+
assert store.load() == ""
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
@pytest.mark.skipif(sys.platform != "win32", reason="Windows DPAPI regression")
|
|
239
|
+
def test_legacy_plaintext_api_key_is_migrated():
|
|
240
|
+
from gui_easyrob.bot.credential_store import CredentialStore
|
|
241
|
+
|
|
242
|
+
with tempfile.TemporaryDirectory(dir=Path(__file__).parent) as temp_dir:
|
|
243
|
+
settings_path = Path(temp_dir) / "settings.ini"
|
|
244
|
+
settings = QSettings(str(settings_path), QSettings.IniFormat)
|
|
245
|
+
settings.setValue("bot/api_key", "legacy-secret")
|
|
246
|
+
settings.sync()
|
|
247
|
+
|
|
248
|
+
store = CredentialStore(settings)
|
|
249
|
+
|
|
250
|
+
assert store.load() == "legacy-secret"
|
|
251
|
+
assert settings.value("bot/api_key") is None
|
|
252
|
+
assert "legacy-secret" not in settings_path.read_text(encoding="utf-8")
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@pytest.mark.skipif(sys.platform != "win32", reason="Windows DPAPI regression")
|
|
256
|
+
def test_loading_protected_api_key_removes_leftover_plaintext():
|
|
257
|
+
from gui_easyrob.bot.credential_store import CredentialStore
|
|
258
|
+
|
|
259
|
+
with tempfile.TemporaryDirectory(dir=Path(__file__).parent) as temp_dir:
|
|
260
|
+
settings = QSettings(str(Path(temp_dir) / "settings.ini"), QSettings.IniFormat)
|
|
261
|
+
store = CredentialStore(settings)
|
|
262
|
+
store.save("protected-secret")
|
|
263
|
+
settings.setValue("bot/api_key", "stale-plaintext")
|
|
264
|
+
settings.sync()
|
|
265
|
+
|
|
266
|
+
assert store.load() == "protected-secret"
|
|
267
|
+
assert settings.value("bot/api_key") is None
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
@pytest.mark.skipif(sys.platform != "win32", reason="Windows DPAPI regression")
|
|
271
|
+
def test_gui_loads_api_key_from_protected_storage():
|
|
272
|
+
from gui_easyrob.bot.credential_store import CredentialStore
|
|
273
|
+
|
|
274
|
+
with tempfile.TemporaryDirectory(dir=Path(__file__).parent) as temp_dir:
|
|
275
|
+
settings = QSettings(str(Path(temp_dir) / "settings.ini"), QSettings.IniFormat)
|
|
276
|
+
CredentialStore(settings).save("protected-secret")
|
|
277
|
+
panel = _SettingsPanel()
|
|
278
|
+
state = SimpleNamespace(bot_settings=settings, bot_panel=panel)
|
|
279
|
+
|
|
280
|
+
EasyROB._load_bot_preferences(state)
|
|
281
|
+
|
|
282
|
+
assert panel.api_key_edit.text() == "protected-secret"
|
|
283
|
+
assert panel.saved is True
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@pytest.mark.skipif(sys.platform != "win32", reason="Windows DPAPI regression")
|
|
287
|
+
def test_gui_saves_api_key_without_plaintext(monkeypatch):
|
|
288
|
+
from gui_easyrob.main import window as window_module
|
|
289
|
+
|
|
290
|
+
monkeypatch.setattr(window_module.QMessageBox, "information", lambda *args: None)
|
|
291
|
+
with tempfile.TemporaryDirectory(dir=Path(__file__).parent) as temp_dir:
|
|
292
|
+
settings = QSettings(str(Path(temp_dir) / "settings.ini"), QSettings.IniFormat)
|
|
293
|
+
panel = _SettingsPanel("new-secret")
|
|
294
|
+
state = SimpleNamespace(bot_settings=settings, bot_panel=panel)
|
|
295
|
+
|
|
296
|
+
EasyROB.save_bot_api_preferences(state)
|
|
297
|
+
|
|
298
|
+
assert settings.value("bot/api_key") is None
|
|
299
|
+
assert panel.saved is True
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
@pytest.mark.skipif(sys.platform != "win32", reason="Windows DPAPI regression")
|
|
303
|
+
def test_api_key_save_reports_settings_write_failure():
|
|
304
|
+
from gui_easyrob.bot.credential_store import CredentialStore, CredentialStoreError
|
|
305
|
+
|
|
306
|
+
class UnwritableSettings:
|
|
307
|
+
def setValue(self, *_):
|
|
308
|
+
pass
|
|
309
|
+
|
|
310
|
+
def remove(self, *_):
|
|
311
|
+
pass
|
|
312
|
+
|
|
313
|
+
def sync(self):
|
|
314
|
+
pass
|
|
315
|
+
|
|
316
|
+
def status(self):
|
|
317
|
+
return QSettings.AccessError
|
|
318
|
+
|
|
319
|
+
with pytest.raises(CredentialStoreError):
|
|
320
|
+
CredentialStore(UnwritableSettings()).save("secret")
|