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,427 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Image browser tab for easyROB workflow outputs.
|
|
3
|
+
|
|
4
|
+
This module provides a lightweight interface to explore, preview, and export
|
|
5
|
+
images generated during the ROBERT workflow.
|
|
6
|
+
|
|
7
|
+
Responsibilities:
|
|
8
|
+
- Scan workflow output folders (CURATE, GENERATE, PREDICT, VERIFY)
|
|
9
|
+
- Display images grouped by workflow stage
|
|
10
|
+
- Provide interaction options (preview, open, copy, save, open folder)
|
|
11
|
+
|
|
12
|
+
Import strategy:
|
|
13
|
+
- Supports dual execution modes:
|
|
14
|
+
1. Local (portable execution)
|
|
15
|
+
2. Installed package (environment / entry point)
|
|
16
|
+
|
|
17
|
+
- Imports use a try/except fallback to ensure compatibility.
|
|
18
|
+
|
|
19
|
+
Notes:
|
|
20
|
+
- Focuses on visualization and file interaction only.
|
|
21
|
+
- No workflow logic or processing is handled here.
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
from utils.utils_gui import (
|
|
27
|
+
QApplication,
|
|
28
|
+
QComboBox,
|
|
29
|
+
QDesktopServices,
|
|
30
|
+
QFileDialog,
|
|
31
|
+
QGridLayout,
|
|
32
|
+
QHBoxLayout,
|
|
33
|
+
QLabel,
|
|
34
|
+
QMenu,
|
|
35
|
+
QMessageBox,
|
|
36
|
+
QPixmap,
|
|
37
|
+
QPushButton,
|
|
38
|
+
QScrollArea,
|
|
39
|
+
QStackedWidget,
|
|
40
|
+
QUrl,
|
|
41
|
+
QVBoxLayout,
|
|
42
|
+
QWidget,
|
|
43
|
+
Qt,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
except ImportError as e:
|
|
47
|
+
from robert.gui_easyrob.utils.utils_gui import (
|
|
48
|
+
QApplication,
|
|
49
|
+
QComboBox,
|
|
50
|
+
QDesktopServices,
|
|
51
|
+
QFileDialog,
|
|
52
|
+
QGridLayout,
|
|
53
|
+
QHBoxLayout,
|
|
54
|
+
QLabel,
|
|
55
|
+
QMenu,
|
|
56
|
+
QMessageBox,
|
|
57
|
+
QPixmap,
|
|
58
|
+
QPushButton,
|
|
59
|
+
QScrollArea,
|
|
60
|
+
QStackedWidget,
|
|
61
|
+
QUrl,
|
|
62
|
+
QVBoxLayout,
|
|
63
|
+
QWidget,
|
|
64
|
+
Qt,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# ---- Standard library ----
|
|
68
|
+
import os
|
|
69
|
+
import json
|
|
70
|
+
import hashlib
|
|
71
|
+
from pathlib import Path
|
|
72
|
+
|
|
73
|
+
from PySide6.QtCore import QObject, Slot
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
IMAGE_FOLDERS = (
|
|
77
|
+
("CURATE", "CURATE"),
|
|
78
|
+
("GENERATE/Raw_data", "GENERATE"),
|
|
79
|
+
("PREDICT", "PREDICT"),
|
|
80
|
+
("PREDICT/csv_test", "PREDICT / external test"),
|
|
81
|
+
("VERIFY", "VERIFY"),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def find_image_files(folder_path):
|
|
86
|
+
"""Return supported image files directly inside a workflow folder."""
|
|
87
|
+
if not os.path.isdir(folder_path):
|
|
88
|
+
return []
|
|
89
|
+
return sorted(
|
|
90
|
+
os.path.join(folder_path, name)
|
|
91
|
+
for name in os.listdir(folder_path)
|
|
92
|
+
if os.path.isfile(os.path.join(folder_path, name))
|
|
93
|
+
and os.path.splitext(name)[1].lower() in {".png", ".jpg", ".jpeg"}
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def build_gallery_state(base_path, catalog=None, model=None):
|
|
98
|
+
"""Build browser data and an ID-to-path map from workflow images."""
|
|
99
|
+
stages = []
|
|
100
|
+
paths = {}
|
|
101
|
+
for folder, label in IMAGE_FOLDERS:
|
|
102
|
+
directory = Path(base_path) / folder
|
|
103
|
+
items = []
|
|
104
|
+
for filename in find_image_files(str(directory)):
|
|
105
|
+
path = Path(filename)
|
|
106
|
+
if catalog is not None and not catalog.include_image(path, model):
|
|
107
|
+
continue
|
|
108
|
+
image_id = "image-" + hashlib.blake2s(str(path).encode("utf-8"), digest_size=8).hexdigest()
|
|
109
|
+
paths[image_id] = path
|
|
110
|
+
items.append({
|
|
111
|
+
"id": image_id,
|
|
112
|
+
"name": path.name,
|
|
113
|
+
"url": QUrl.fromLocalFile(str(path)).toString(),
|
|
114
|
+
})
|
|
115
|
+
if items:
|
|
116
|
+
stages.append({"id": folder, "label": label, "images": items})
|
|
117
|
+
return {"stages": stages, "total": len(paths)}, paths
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class ImageActionBridge(QObject):
|
|
121
|
+
"""Expose only listed image actions to the local browser page."""
|
|
122
|
+
|
|
123
|
+
def __init__(self, parent=None):
|
|
124
|
+
super().__init__(parent)
|
|
125
|
+
self._paths = {}
|
|
126
|
+
|
|
127
|
+
def set_paths(self, paths):
|
|
128
|
+
self._paths = dict(paths)
|
|
129
|
+
|
|
130
|
+
@Slot(str, str)
|
|
131
|
+
def performAction(self, image_id, action):
|
|
132
|
+
path = self._paths.get(image_id)
|
|
133
|
+
if path is None or not path.is_file():
|
|
134
|
+
return
|
|
135
|
+
if action == "open":
|
|
136
|
+
QDesktopServices.openUrl(QUrl.fromLocalFile(str(path)))
|
|
137
|
+
elif action == "folder":
|
|
138
|
+
QDesktopServices.openUrl(QUrl.fromLocalFile(str(path.parent)))
|
|
139
|
+
elif action == "copy":
|
|
140
|
+
QApplication.clipboard().setPixmap(QPixmap(str(path)))
|
|
141
|
+
elif action == "save":
|
|
142
|
+
target_path, _ = QFileDialog.getSaveFileName(
|
|
143
|
+
self.parent(), "Save Image As", path.name, "Images (*.png *.jpg *.jpeg)"
|
|
144
|
+
)
|
|
145
|
+
if target_path:
|
|
146
|
+
QPixmap(str(path)).save(target_path)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class ImagesTab(QWidget):
|
|
150
|
+
"""Images tab for displaying images from multiple folders as workflow results."""
|
|
151
|
+
|
|
152
|
+
def __init__(self, main_tab_widget, image_folders, file_path):
|
|
153
|
+
super().__init__()
|
|
154
|
+
|
|
155
|
+
# Store references and base workflow path
|
|
156
|
+
self.main_tab_widget = main_tab_widget
|
|
157
|
+
self.image_folders = image_folders
|
|
158
|
+
self.base_path = os.path.dirname(file_path)
|
|
159
|
+
self.catalog = None
|
|
160
|
+
self.model = None
|
|
161
|
+
self.folder_widgets = {}
|
|
162
|
+
|
|
163
|
+
# Retain the widget view for fast headless tests and browser failures.
|
|
164
|
+
self._views = QStackedWidget(self)
|
|
165
|
+
self._legacy_content = QWidget(self)
|
|
166
|
+
self.layout = QVBoxLayout(self._legacy_content)
|
|
167
|
+
outer_layout = QVBoxLayout(self)
|
|
168
|
+
outer_layout.setContentsMargins(0, 0, 0, 0)
|
|
169
|
+
outer_layout.addWidget(self._views)
|
|
170
|
+
self._views.addWidget(self._legacy_content)
|
|
171
|
+
self._web_view = None
|
|
172
|
+
self._web_ready = False
|
|
173
|
+
self._bridge = ImageActionBridge(self)
|
|
174
|
+
self.gallery_state = {"stages": [], "total": 0}
|
|
175
|
+
|
|
176
|
+
# Top section: title + subtitle (+ inline help)
|
|
177
|
+
# Title
|
|
178
|
+
title_label = QLabel("Workflow Images")
|
|
179
|
+
title_label.setStyleSheet("font-weight: bold; font-size: 14px;")
|
|
180
|
+
|
|
181
|
+
# Subtitle row (subtitle + help button inline)
|
|
182
|
+
subtitle_row = QHBoxLayout()
|
|
183
|
+
subtitle_row.setSpacing(6)
|
|
184
|
+
|
|
185
|
+
subtitle_label = QLabel("Browse, open and export generated images")
|
|
186
|
+
subtitle_label.setStyleSheet("color: gray; font-size: 12px;")
|
|
187
|
+
|
|
188
|
+
# Help button inline with subtitle
|
|
189
|
+
help_button = QPushButton("?")
|
|
190
|
+
help_button.setFixedSize(18, 18)
|
|
191
|
+
help_button.setStyleSheet("font-size: 11px;")
|
|
192
|
+
help_button.setToolTip(
|
|
193
|
+
"Double-click: Open image\n"
|
|
194
|
+
"Right-click: Copy, Save, or Open folder"
|
|
195
|
+
)
|
|
196
|
+
help_button.clicked.connect(self.show_help_dialog)
|
|
197
|
+
|
|
198
|
+
# Build subtitle row
|
|
199
|
+
subtitle_row.addWidget(subtitle_label)
|
|
200
|
+
subtitle_row.addWidget(help_button)
|
|
201
|
+
subtitle_row.addStretch() # Push everything left
|
|
202
|
+
|
|
203
|
+
# Add to main layout
|
|
204
|
+
self.layout.addWidget(title_label)
|
|
205
|
+
self.layout.addLayout(subtitle_row)
|
|
206
|
+
|
|
207
|
+
# A single view selector keeps Images free of nested tab bars.
|
|
208
|
+
view_row = QHBoxLayout()
|
|
209
|
+
view_row.addWidget(QLabel("View"))
|
|
210
|
+
self.view_selector = QComboBox()
|
|
211
|
+
self.view_selector.setMaximumWidth(280)
|
|
212
|
+
view_row.addWidget(self.view_selector)
|
|
213
|
+
view_row.addStretch()
|
|
214
|
+
self.layout.addLayout(view_row)
|
|
215
|
+
self.folder_tabs = QStackedWidget()
|
|
216
|
+
self.view_selector.currentIndexChanged.connect(self.folder_tabs.setCurrentIndex)
|
|
217
|
+
self.layout.addWidget(self.folder_tabs)
|
|
218
|
+
|
|
219
|
+
self.check_for_images()
|
|
220
|
+
|
|
221
|
+
def showEvent(self, event):
|
|
222
|
+
super().showEvent(event)
|
|
223
|
+
self.activate_web()
|
|
224
|
+
|
|
225
|
+
def activate_web(self):
|
|
226
|
+
"""Start Chromium only when this result view is opened interactively."""
|
|
227
|
+
if QApplication.platformName() == "offscreen" and os.environ.get("EASYROB_WEBENGINE_TEST") != "1":
|
|
228
|
+
return
|
|
229
|
+
if self._web_view is not None:
|
|
230
|
+
return
|
|
231
|
+
from PySide6.QtWebChannel import QWebChannel
|
|
232
|
+
from PySide6.QtWebEngineWidgets import QWebEngineView
|
|
233
|
+
|
|
234
|
+
self._web_view = QWebEngineView(self)
|
|
235
|
+
self._web_channel = QWebChannel(self._web_view.page())
|
|
236
|
+
self._web_channel.registerObject("imageActions", self._bridge)
|
|
237
|
+
self._web_view.page().setWebChannel(self._web_channel)
|
|
238
|
+
self._web_view.loadFinished.connect(self._on_web_loaded)
|
|
239
|
+
self._views.addWidget(self._web_view)
|
|
240
|
+
page_path = Path(__file__).resolve().parent.parent / "web" / "images.html"
|
|
241
|
+
self._web_view.setUrl(QUrl.fromLocalFile(str(page_path)))
|
|
242
|
+
|
|
243
|
+
def _on_web_loaded(self, success):
|
|
244
|
+
if not success:
|
|
245
|
+
self._views.setCurrentWidget(self._legacy_content)
|
|
246
|
+
return
|
|
247
|
+
self._web_ready = True
|
|
248
|
+
self._views.setCurrentWidget(self._web_view)
|
|
249
|
+
self._sync_web()
|
|
250
|
+
|
|
251
|
+
def _sync_web(self):
|
|
252
|
+
state, paths = build_gallery_state(self.base_path, self.catalog, self.model)
|
|
253
|
+
self.gallery_state = state
|
|
254
|
+
self._bridge.set_paths(paths)
|
|
255
|
+
if self._web_ready:
|
|
256
|
+
payload = json.dumps(state, ensure_ascii=False)
|
|
257
|
+
self._web_view.page().runJavaScript(f"window.easyrobGallery.setData({payload})")
|
|
258
|
+
|
|
259
|
+
def show_help_dialog(self):
|
|
260
|
+
"""Show usage instructions."""
|
|
261
|
+
msg = QMessageBox(self)
|
|
262
|
+
msg.setWindowTitle("How to use")
|
|
263
|
+
msg.setText(
|
|
264
|
+
"Image interaction:\n\n"
|
|
265
|
+
"• Double-click → Open image\n"
|
|
266
|
+
"• Right-click → Copy, Save, or Open folder\n\n"
|
|
267
|
+
"Images are grouped by workflow stage."
|
|
268
|
+
)
|
|
269
|
+
msg.exec()
|
|
270
|
+
|
|
271
|
+
def refresh_with_new_path(self, file_path, catalog=None, model=None):
|
|
272
|
+
"""Update image base path and refresh image tabs."""
|
|
273
|
+
selected_view = self.view_selector.currentText()
|
|
274
|
+
self.base_path = os.path.dirname(file_path)
|
|
275
|
+
self.catalog = catalog
|
|
276
|
+
self.model = model
|
|
277
|
+
self.clear_image_tabs()
|
|
278
|
+
self.check_for_images()
|
|
279
|
+
index = self.view_selector.findText(selected_view)
|
|
280
|
+
if index >= 0:
|
|
281
|
+
self.view_selector.setCurrentIndex(index)
|
|
282
|
+
|
|
283
|
+
def clear_image_tabs(self):
|
|
284
|
+
"""Clear all image folders and their widgets."""
|
|
285
|
+
self.view_selector.blockSignals(True)
|
|
286
|
+
self.view_selector.clear()
|
|
287
|
+
self.view_selector.blockSignals(False)
|
|
288
|
+
while self.folder_tabs.count():
|
|
289
|
+
widget = self.folder_tabs.widget(0)
|
|
290
|
+
if widget:
|
|
291
|
+
self.folder_tabs.removeWidget(widget)
|
|
292
|
+
widget.deleteLater()
|
|
293
|
+
self.folder_widgets.clear()
|
|
294
|
+
|
|
295
|
+
def check_for_images(self):
|
|
296
|
+
"""Scan folders and update tabs with new images."""
|
|
297
|
+
folder_names = {
|
|
298
|
+
"CURATE": "CURATE",
|
|
299
|
+
"GENERATE/Raw_data": "GENERATE",
|
|
300
|
+
"PREDICT": "PREDICT",
|
|
301
|
+
"PREDICT/csv_test": "PREDICT / external test",
|
|
302
|
+
"VERIFY": "VERIFY",
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
folder_order = [
|
|
306
|
+
"CURATE", "GENERATE/Raw_data", "PREDICT", "PREDICT/csv_test", "VERIFY",
|
|
307
|
+
]
|
|
308
|
+
|
|
309
|
+
for folder in folder_order:
|
|
310
|
+
full_folder_path = os.path.join(self.base_path, folder)
|
|
311
|
+
if not os.path.exists(full_folder_path):
|
|
312
|
+
continue
|
|
313
|
+
|
|
314
|
+
image_files = find_image_files(full_folder_path)
|
|
315
|
+
if self.catalog is not None:
|
|
316
|
+
image_files = [
|
|
317
|
+
path for path in image_files
|
|
318
|
+
if self.catalog.include_image(Path(path), self.model)
|
|
319
|
+
]
|
|
320
|
+
if not image_files:
|
|
321
|
+
continue
|
|
322
|
+
|
|
323
|
+
if folder not in self.folder_widgets:
|
|
324
|
+
folder_widget = QWidget()
|
|
325
|
+
folder_layout = QVBoxLayout(folder_widget)
|
|
326
|
+
|
|
327
|
+
scroll_area = QScrollArea()
|
|
328
|
+
scroll_area.setWidgetResizable(True)
|
|
329
|
+
|
|
330
|
+
image_grid = QGridLayout()
|
|
331
|
+
container = QWidget()
|
|
332
|
+
container.setLayout(image_grid)
|
|
333
|
+
scroll_area.setWidget(container)
|
|
334
|
+
|
|
335
|
+
folder_layout.addWidget(scroll_area)
|
|
336
|
+
folder_widget.setLayout(folder_layout)
|
|
337
|
+
|
|
338
|
+
tab_name = folder_names.get(folder, os.path.basename(folder))
|
|
339
|
+
self.folder_tabs.addWidget(folder_widget)
|
|
340
|
+
self.view_selector.addItem(tab_name)
|
|
341
|
+
self.folder_widgets[folder] = image_grid
|
|
342
|
+
|
|
343
|
+
image_grid = self.folder_widgets[folder]
|
|
344
|
+
|
|
345
|
+
# Clear old images
|
|
346
|
+
while image_grid.count():
|
|
347
|
+
item = image_grid.takeAt(0)
|
|
348
|
+
if item.widget():
|
|
349
|
+
item.widget().deleteLater()
|
|
350
|
+
|
|
351
|
+
row, col = 0, 0
|
|
352
|
+
max_columns = 3
|
|
353
|
+
|
|
354
|
+
for img_path in image_files:
|
|
355
|
+
image_label = ImageLabel(img_path, size=300)
|
|
356
|
+
image_grid.addWidget(image_label, row, col)
|
|
357
|
+
|
|
358
|
+
col += 1
|
|
359
|
+
if col >= max_columns:
|
|
360
|
+
col = 0
|
|
361
|
+
row += 1
|
|
362
|
+
|
|
363
|
+
self._sync_web()
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
class ImageLabel(QLabel):
|
|
367
|
+
"""Custom QLabel for displaying an image with context menu and double-click support."""
|
|
368
|
+
|
|
369
|
+
def __init__(self, image_path, size=400):
|
|
370
|
+
super().__init__()
|
|
371
|
+
|
|
372
|
+
self.image_path = image_path
|
|
373
|
+
self.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
374
|
+
self.setToolTip("Right-click for options\nDouble-click to open")
|
|
375
|
+
|
|
376
|
+
pixmap = QPixmap(self.image_path)
|
|
377
|
+
|
|
378
|
+
if pixmap.isNull():
|
|
379
|
+
self.setText("Failed to load image.")
|
|
380
|
+
else:
|
|
381
|
+
self.setPixmap(
|
|
382
|
+
pixmap.scaled(
|
|
383
|
+
size,
|
|
384
|
+
size,
|
|
385
|
+
Qt.AspectRatioMode.KeepAspectRatio,
|
|
386
|
+
Qt.TransformationMode.SmoothTransformation,
|
|
387
|
+
)
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
|
391
|
+
self.customContextMenuRequested.connect(self.show_context_menu)
|
|
392
|
+
|
|
393
|
+
def mouseDoubleClickEvent(self, event):
|
|
394
|
+
"""Open image on double-click."""
|
|
395
|
+
QDesktopServices.openUrl(QUrl.fromLocalFile(self.image_path))
|
|
396
|
+
|
|
397
|
+
def show_context_menu(self, position):
|
|
398
|
+
"""Create context menu."""
|
|
399
|
+
menu = QMenu(self)
|
|
400
|
+
|
|
401
|
+
copy_action = menu.addAction("Copy image")
|
|
402
|
+
open_action = menu.addAction("Open image")
|
|
403
|
+
open_folder_action = menu.addAction("Open containing folder")
|
|
404
|
+
save_as_action = menu.addAction("Save as...")
|
|
405
|
+
|
|
406
|
+
action = menu.exec(self.mapToGlobal(position))
|
|
407
|
+
|
|
408
|
+
if action == copy_action:
|
|
409
|
+
clipboard = QApplication.clipboard()
|
|
410
|
+
clipboard.setPixmap(QPixmap(self.image_path))
|
|
411
|
+
|
|
412
|
+
elif action == open_action:
|
|
413
|
+
QDesktopServices.openUrl(QUrl.fromLocalFile(self.image_path))
|
|
414
|
+
|
|
415
|
+
elif action == open_folder_action:
|
|
416
|
+
folder = os.path.dirname(self.image_path)
|
|
417
|
+
QDesktopServices.openUrl(QUrl.fromLocalFile(folder))
|
|
418
|
+
|
|
419
|
+
elif action == save_as_action:
|
|
420
|
+
target_path, _ = QFileDialog.getSaveFileName(
|
|
421
|
+
self,
|
|
422
|
+
"Save Image As",
|
|
423
|
+
os.path.basename(self.image_path),
|
|
424
|
+
"Images (*.png *.jpg *.jpeg)",
|
|
425
|
+
)
|
|
426
|
+
if target_path:
|
|
427
|
+
QPixmap(self.image_path).save(target_path)
|