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,499 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
(() => {
|
|
4
|
+
let bridge = null;
|
|
5
|
+
let activeView = null;
|
|
6
|
+
let sourceSignature = "";
|
|
7
|
+
let reportPage = 0;
|
|
8
|
+
let predictionPage = 0;
|
|
9
|
+
let sortColumn = "";
|
|
10
|
+
let descending = false;
|
|
11
|
+
let plotType = "observed";
|
|
12
|
+
let plotData = null;
|
|
13
|
+
let requestId = 0;
|
|
14
|
+
let inspectedPoint = "";
|
|
15
|
+
let diagnosticKey = "";
|
|
16
|
+
let predictionNumeric = null;
|
|
17
|
+
const hiddenGroups = new Set();
|
|
18
|
+
const svgNS = "http://www.w3.org/2000/svg";
|
|
19
|
+
// Match the blue training and red test markers in the generated report figures.
|
|
20
|
+
const colors = { CV: "#0000ff", Test: "#ff0000", External: "#ff0000", Data: "#0000ff",
|
|
21
|
+
"Typical 80%": "#0000ff", "High leverage 20%": "#ff0000" };
|
|
22
|
+
|
|
23
|
+
function setOptions(element, options) {
|
|
24
|
+
const oldValue = element.value;
|
|
25
|
+
element.replaceChildren();
|
|
26
|
+
for (const option of options) {
|
|
27
|
+
const item = document.createElement("option");
|
|
28
|
+
item.value = option.value;
|
|
29
|
+
item.textContent = option.label;
|
|
30
|
+
element.appendChild(item);
|
|
31
|
+
}
|
|
32
|
+
if (options.some(option => option.value === oldValue)) element.value = oldValue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function errorFor(name, message) {
|
|
36
|
+
const element = document.getElementById(`${name}-error`);
|
|
37
|
+
element.hidden = !message;
|
|
38
|
+
element.textContent = message || "";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function open(name) {
|
|
42
|
+
const ids = { Report: "report-view", Predictions: "prediction-view", "Interactive plots": "plot-view" };
|
|
43
|
+
activeView = ids[name] || null;
|
|
44
|
+
for (const id of Object.values(ids)) document.getElementById(id).hidden = id !== activeView;
|
|
45
|
+
if (!activeView) return;
|
|
46
|
+
document.getElementById(activeView).scrollIntoView({ behavior: "smooth", block: "start" });
|
|
47
|
+
if (name === "Report") loadReport();
|
|
48
|
+
if (name === "Predictions") loadPredictions();
|
|
49
|
+
if (name === "Interactive plots") loadPlot();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function resetPredictionSelection() {
|
|
53
|
+
predictionPage = 0;
|
|
54
|
+
sortColumn = "";
|
|
55
|
+
descending = false;
|
|
56
|
+
diagnosticKey = "";
|
|
57
|
+
document.getElementById("prediction-search").value = "";
|
|
58
|
+
document.getElementById("prediction-histogram").hidden = true;
|
|
59
|
+
predictionNumeric = null;
|
|
60
|
+
const statistics = document.getElementById("prediction-numeric");
|
|
61
|
+
statistics.dataset.snapshot = "";
|
|
62
|
+
statistics.replaceChildren();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function render(results) {
|
|
66
|
+
const viewNames = { "report-view": "Report", "prediction-view": "Predictions",
|
|
67
|
+
"plot-view": "Interactive plots" };
|
|
68
|
+
if (activeView && !results.available[viewNames[activeView]]) {
|
|
69
|
+
open(null);
|
|
70
|
+
if (bridge) bridge.performAction("activeResultView", "");
|
|
71
|
+
}
|
|
72
|
+
const signature = JSON.stringify([results.revision, results.selectedModel,
|
|
73
|
+
results.files, results.predictionFiles]);
|
|
74
|
+
if (sourceSignature === signature) return;
|
|
75
|
+
sourceSignature = signature;
|
|
76
|
+
reportPage = 0;
|
|
77
|
+
resetPredictionSelection();
|
|
78
|
+
setOptions(document.getElementById("report-file"), (results.files.Report || []).map((label, index) => ({ value: String(index), label })));
|
|
79
|
+
setOptions(document.getElementById("prediction-file"), (results.predictionFiles || []).map(item => ({ value: item.key, label: item.label })));
|
|
80
|
+
setOptions(document.getElementById("plot-file"), (results.files["Interactive plots"] || []).map((label, index) => ({ value: String(index), label })));
|
|
81
|
+
if (activeView === "report-view") loadReport();
|
|
82
|
+
if (activeView === "prediction-view") loadPredictions();
|
|
83
|
+
if (activeView === "plot-view") loadPlot();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function loadReport() {
|
|
87
|
+
if (!bridge || !document.getElementById("report-file").options.length) return;
|
|
88
|
+
const token = ++requestId;
|
|
89
|
+
errorFor("report", "");
|
|
90
|
+
bridge.getReportPage(Number(document.getElementById("report-file").value), reportPage,
|
|
91
|
+
Number(document.getElementById("report-zoom").value), payload => {
|
|
92
|
+
if (token !== requestId) return;
|
|
93
|
+
const result = JSON.parse(payload);
|
|
94
|
+
if (result.error) return errorFor("report", result.error);
|
|
95
|
+
reportPage = result.page;
|
|
96
|
+
document.getElementById("report-image").src = result.image;
|
|
97
|
+
document.getElementById("report-position").textContent = `Page ${result.page + 1} / ${result.pages}`;
|
|
98
|
+
document.getElementById("report-previous").disabled = result.page === 0;
|
|
99
|
+
document.getElementById("report-next").disabled = result.page >= result.pages - 1;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function loadPredictions() {
|
|
104
|
+
const key = document.getElementById("prediction-file").value;
|
|
105
|
+
if (!bridge || !key) return;
|
|
106
|
+
const token = ++requestId;
|
|
107
|
+
errorFor("prediction", "");
|
|
108
|
+
bridge.getPredictionTable(key, document.getElementById("prediction-search").value,
|
|
109
|
+
sortColumn, descending, predictionPage, payload => {
|
|
110
|
+
if (token !== requestId) return;
|
|
111
|
+
const result = JSON.parse(payload);
|
|
112
|
+
if (result.error) return errorFor("prediction", result.error);
|
|
113
|
+
predictionPage = result.page;
|
|
114
|
+
const head = document.getElementById("prediction-head");
|
|
115
|
+
const body = document.getElementById("prediction-body");
|
|
116
|
+
head.replaceChildren();
|
|
117
|
+
body.replaceChildren();
|
|
118
|
+
const header = document.createElement("tr");
|
|
119
|
+
for (const column of result.columns) {
|
|
120
|
+
const cell = document.createElement("th");
|
|
121
|
+
if (column === result.nameColumn) cell.classList.add("identifier-column");
|
|
122
|
+
if (column !== "Image") {
|
|
123
|
+
const button = document.createElement("button");
|
|
124
|
+
button.type = "button";
|
|
125
|
+
button.dataset.sortColumn = column;
|
|
126
|
+
button.textContent = `${column}${sortColumn === column ? (descending ? " ↓" : " ↑") : " ↕"}`;
|
|
127
|
+
button.setAttribute("aria-label", `Sort by ${column}`);
|
|
128
|
+
cell.appendChild(button);
|
|
129
|
+
} else cell.textContent = column;
|
|
130
|
+
header.appendChild(cell);
|
|
131
|
+
}
|
|
132
|
+
head.appendChild(header);
|
|
133
|
+
for (const row of result.rows) {
|
|
134
|
+
const line = document.createElement("tr");
|
|
135
|
+
row.forEach((value, index) => {
|
|
136
|
+
const cell = document.createElement("td");
|
|
137
|
+
if (result.columns[index] === result.nameColumn) cell.classList.add("identifier-column");
|
|
138
|
+
if (result.columns[index] === "Image" && value) {
|
|
139
|
+
const image = document.createElement("img");
|
|
140
|
+
image.src = value;
|
|
141
|
+
image.alt = "Molecule";
|
|
142
|
+
image.loading = "lazy";
|
|
143
|
+
cell.appendChild(image);
|
|
144
|
+
} else cell.textContent = value;
|
|
145
|
+
line.appendChild(cell);
|
|
146
|
+
});
|
|
147
|
+
body.appendChild(line);
|
|
148
|
+
}
|
|
149
|
+
if (!result.rows.length) {
|
|
150
|
+
const line = document.createElement("tr");
|
|
151
|
+
const cell = document.createElement("td");
|
|
152
|
+
cell.colSpan = Math.max(1, result.columns.length);
|
|
153
|
+
cell.className = "prediction-empty";
|
|
154
|
+
cell.textContent = "No rows match this search. Try another identifier.";
|
|
155
|
+
line.appendChild(cell);
|
|
156
|
+
body.appendChild(line);
|
|
157
|
+
}
|
|
158
|
+
document.getElementById("prediction-count").textContent = `${result.total} of ${result.allRows} rows`;
|
|
159
|
+
document.getElementById("prediction-columns").textContent = `${result.columns.length} columns`;
|
|
160
|
+
document.getElementById("prediction-identifier").textContent = result.nameColumn
|
|
161
|
+
? `Identifier: ${result.nameColumn}` : "No identifier column detected";
|
|
162
|
+
document.getElementById("prediction-position").textContent = `Page ${result.page + 1} / ${result.pages}`;
|
|
163
|
+
document.getElementById("prediction-previous").disabled = result.page === 0;
|
|
164
|
+
document.getElementById("prediction-next").disabled = result.page >= result.pages - 1;
|
|
165
|
+
document.getElementById("prediction-search").placeholder = result.nameColumn ? `Search ${result.nameColumn}` : "Identifier unavailable";
|
|
166
|
+
document.getElementById("prediction-search").disabled = !result.nameColumn;
|
|
167
|
+
renderPredictionScenario(result.scenario);
|
|
168
|
+
predictionNumeric = result.numeric;
|
|
169
|
+
if (document.querySelector(".prediction-statistics").open) renderPredictionStatistics(result.numeric);
|
|
170
|
+
if (document.querySelector(".prediction-insights").open) loadDiagnostics();
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function appendRecommendation(target, value) {
|
|
175
|
+
const almosLink = '<a href="https://github.com/MiguelMartzFdez/almos">ALMOS</a>';
|
|
176
|
+
value.split(almosLink).forEach((part, index) => {
|
|
177
|
+
if (index) {
|
|
178
|
+
const link = document.createElement("button");
|
|
179
|
+
link.type = "button";
|
|
180
|
+
link.className = "inline-link";
|
|
181
|
+
link.dataset.action = "openAlmos";
|
|
182
|
+
link.textContent = "ALMOS ↗";
|
|
183
|
+
target.appendChild(link);
|
|
184
|
+
}
|
|
185
|
+
target.appendChild(document.createTextNode(part));
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function renderPredictionScenario(result) {
|
|
190
|
+
const scenario = document.getElementById("prediction-scenario");
|
|
191
|
+
scenario.replaceChildren();
|
|
192
|
+
scenario.dataset.state = result.state;
|
|
193
|
+
const marker = document.createElement("div");
|
|
194
|
+
marker.className = "scenario-marker";
|
|
195
|
+
marker.textContent = result.state === "FAILED" ? "!" : result.state === "STRONG" ? "✓" : "i";
|
|
196
|
+
const content = document.createElement("div");
|
|
197
|
+
content.className = "scenario-content";
|
|
198
|
+
const heading = document.createElement("div");
|
|
199
|
+
heading.className = "scenario-heading";
|
|
200
|
+
const title = document.createElement("strong");
|
|
201
|
+
title.textContent = "Model assessment";
|
|
202
|
+
const badge = document.createElement("span");
|
|
203
|
+
badge.className = "scenario-state";
|
|
204
|
+
badge.textContent = result.state;
|
|
205
|
+
heading.append(title, badge);
|
|
206
|
+
const message = document.createElement("p");
|
|
207
|
+
message.textContent = (result.messages || []).map(value => value
|
|
208
|
+
.replace(/^CheckML score is /, "Interpolation score (CheckML) is ")
|
|
209
|
+
.replace(/^No valid CheckML score/, "No valid Interpolation score")).join(" ");
|
|
210
|
+
content.append(heading, message);
|
|
211
|
+
if (result.recommendations?.length) {
|
|
212
|
+
const advice = document.createElement("div");
|
|
213
|
+
advice.className = "scenario-advice";
|
|
214
|
+
const label = document.createElement("small");
|
|
215
|
+
label.textContent = "SUGGESTED NEXT STEP";
|
|
216
|
+
const copy = document.createElement("p");
|
|
217
|
+
appendRecommendation(copy, result.recommendations.join(" "));
|
|
218
|
+
advice.append(label, copy);
|
|
219
|
+
content.appendChild(advice);
|
|
220
|
+
}
|
|
221
|
+
scenario.append(marker, content);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function renderPredictionStatistics(numeric) {
|
|
225
|
+
const grid = document.getElementById("prediction-numeric");
|
|
226
|
+
const signature = JSON.stringify(numeric);
|
|
227
|
+
if (grid.dataset.snapshot === signature) return;
|
|
228
|
+
grid.dataset.snapshot = signature;
|
|
229
|
+
grid.replaceChildren();
|
|
230
|
+
for (const [column, stats] of Object.entries(numeric)) {
|
|
231
|
+
if (stats.mean === null || stats.mean === undefined) continue;
|
|
232
|
+
const card = document.createElement("div");
|
|
233
|
+
card.className = "prediction-stat-card";
|
|
234
|
+
const heading = document.createElement("strong");
|
|
235
|
+
heading.textContent = column;
|
|
236
|
+
const range = document.createElement("p");
|
|
237
|
+
range.textContent = `${Number(stats.min).toPrecision(3)} – ${Number(stats.max).toPrecision(3)} range`;
|
|
238
|
+
const detail = document.createElement("small");
|
|
239
|
+
detail.textContent = `Median ${Number(stats.median).toPrecision(3)} · Mean ${Number(stats.mean).toPrecision(3)}`;
|
|
240
|
+
const histogram = document.createElement("button");
|
|
241
|
+
histogram.type = "button";
|
|
242
|
+
histogram.className = "histogram-link";
|
|
243
|
+
histogram.dataset.histogram = column;
|
|
244
|
+
histogram.textContent = "View distribution →";
|
|
245
|
+
card.append(heading, range, detail, histogram);
|
|
246
|
+
grid.appendChild(card);
|
|
247
|
+
}
|
|
248
|
+
if (!grid.children.length) grid.textContent = "No numeric columns are available for this dataset.";
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function loadDiagnostics() {
|
|
252
|
+
const key = document.getElementById("prediction-file").value;
|
|
253
|
+
if (!bridge || !key || key === diagnosticKey) return;
|
|
254
|
+
diagnosticKey = key;
|
|
255
|
+
bridge.getPredictionDiagnostics(key, payload => {
|
|
256
|
+
if (key !== document.getElementById("prediction-file").value) return;
|
|
257
|
+
const result = JSON.parse(payload);
|
|
258
|
+
const grid = document.getElementById("prediction-diagnostics");
|
|
259
|
+
grid.replaceChildren();
|
|
260
|
+
if (result.error) { grid.textContent = result.error; return; }
|
|
261
|
+
const cards = [
|
|
262
|
+
["Model performance", result.scoreImage],
|
|
263
|
+
[result.boundaryScore === null ? "Boundary robustness" : `Boundary robustness · ${result.boundaryScore}/10`, result.boundaryImage],
|
|
264
|
+
["External validation", result.externalImage],
|
|
265
|
+
];
|
|
266
|
+
for (const [title, source] of cards) {
|
|
267
|
+
if (!source) continue;
|
|
268
|
+
const card = document.createElement("div");
|
|
269
|
+
card.className = "diagnostic-card";
|
|
270
|
+
const heading = document.createElement("strong");
|
|
271
|
+
heading.textContent = title;
|
|
272
|
+
const image = document.createElement("img");
|
|
273
|
+
image.src = source;
|
|
274
|
+
image.alt = title;
|
|
275
|
+
card.append(heading, image);
|
|
276
|
+
grid.appendChild(card);
|
|
277
|
+
}
|
|
278
|
+
if (!grid.children.length) grid.textContent = "No report diagnostics are available for this model.";
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function loadHistogram(column) {
|
|
283
|
+
const key = document.getElementById("prediction-file").value;
|
|
284
|
+
bridge.getPredictionHistogram(key, column, payload => {
|
|
285
|
+
if (key !== document.getElementById("prediction-file").value) return;
|
|
286
|
+
const result = JSON.parse(payload);
|
|
287
|
+
if (result.error) return errorFor("prediction", result.error);
|
|
288
|
+
const panel = document.getElementById("prediction-histogram");
|
|
289
|
+
const svg = document.getElementById("histogram-svg");
|
|
290
|
+
panel.hidden = false;
|
|
291
|
+
document.getElementById("histogram-title").textContent = `Distribution of ${column}`;
|
|
292
|
+
svg.replaceChildren();
|
|
293
|
+
const top = 25, bottom = 205, left = 43, right = 595;
|
|
294
|
+
const maximum = Math.max(1, ...result.counts);
|
|
295
|
+
const width = (right - left) / result.counts.length;
|
|
296
|
+
result.counts.forEach((count, index) => {
|
|
297
|
+
const height = count / maximum * (bottom - top);
|
|
298
|
+
svg.appendChild(svgElement("rect", { x: left + index * width + 2, y: bottom - height,
|
|
299
|
+
width: Math.max(1, width - 4), height, rx: 3, fill: "#0000ff" }));
|
|
300
|
+
});
|
|
301
|
+
svg.appendChild(svgElement("text", { x: left, y: 230, class: "plot-tick" }, Number(result.edges[0]).toPrecision(3)));
|
|
302
|
+
svg.appendChild(svgElement("text", { x: right, y: 230, "text-anchor": "end", class: "plot-tick" }, Number(result.edges.at(-1)).toPrecision(3)));
|
|
303
|
+
svg.appendChild(svgElement("text", { x: left, y: 18, class: "plot-tick" }, `${maximum} rows`));
|
|
304
|
+
panel.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function svgElement(name, attributes = {}, label = "") {
|
|
309
|
+
const element = document.createElementNS(svgNS, name);
|
|
310
|
+
for (const [key, value] of Object.entries(attributes)) element.setAttribute(key, String(value));
|
|
311
|
+
if (label) element.textContent = label;
|
|
312
|
+
return element;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function drawLine(svg, x1, y1, x2, y2, dashed = false) {
|
|
316
|
+
svg.appendChild(svgElement("line", { x1, y1, x2, y2, stroke: "#808080",
|
|
317
|
+
"stroke-width": 1, "stroke-dasharray": dashed ? "5 5" : "" }));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function inspectPoint(point, williams) {
|
|
321
|
+
const signature = `${williams}:${point.index}`;
|
|
322
|
+
if (inspectedPoint === signature) return;
|
|
323
|
+
inspectedPoint = signature;
|
|
324
|
+
const format = value => Number(value).toPrecision(4);
|
|
325
|
+
const lines = [point.label, `Group: ${point.group}`];
|
|
326
|
+
if (williams) lines.push(`Leverage: ${format(point.x)}`, `Standardized residual: ${format(point.y)}`);
|
|
327
|
+
if (point.observed !== null) lines.push(`Observed: ${format(point.observed)}`);
|
|
328
|
+
if (point.predicted !== null) lines.push(`Predicted: ${format(point.predicted)}`);
|
|
329
|
+
if (!williams) {
|
|
330
|
+
if (point.residual !== null) lines.push(`Residual: ${format(point.residual)}`);
|
|
331
|
+
if (point.outlier !== null) lines.push(`Outlier score: ${format(point.outlier)}`);
|
|
332
|
+
}
|
|
333
|
+
document.getElementById("plot-point-details").textContent = lines.join("\n");
|
|
334
|
+
const image = document.getElementById("plot-molecule");
|
|
335
|
+
image.hidden = true;
|
|
336
|
+
bridge.getPlotMolecule(Number(document.getElementById("plot-file").value), point.index, williams, source => {
|
|
337
|
+
if (inspectedPoint !== signature) return;
|
|
338
|
+
image.hidden = !source;
|
|
339
|
+
if (source) image.src = source;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function drawPlot() {
|
|
344
|
+
if (!plotData) return;
|
|
345
|
+
const svg = document.getElementById("plot-svg");
|
|
346
|
+
const fallback = document.getElementById("williams-fallback");
|
|
347
|
+
svg.replaceChildren();
|
|
348
|
+
fallback.hidden = true;
|
|
349
|
+
const williams = plotType === "williams";
|
|
350
|
+
const points = williams ? plotData.williams : plotData.points;
|
|
351
|
+
if (williams && !points.length && plotData.williamsImage) {
|
|
352
|
+
svg.hidden = true;
|
|
353
|
+
fallback.src = plotData.williamsImage;
|
|
354
|
+
fallback.hidden = false;
|
|
355
|
+
document.getElementById("plot-legend").replaceChildren();
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
svg.hidden = false;
|
|
359
|
+
const coordinates = points.map(point => ({ ...point,
|
|
360
|
+
x: williams ? point.x : plotType === "outlier" ? point.outlier : point.observed,
|
|
361
|
+
y: williams ? point.y : plotType === "outlier" ? point.outlier : point.predicted,
|
|
362
|
+
})).filter(point => Number.isFinite(point.x) && Number.isFinite(point.y));
|
|
363
|
+
const valuesX = coordinates.map(point => point.x);
|
|
364
|
+
const valuesY = coordinates.map(point => point.y);
|
|
365
|
+
const threshold = plotData.threshold || 2;
|
|
366
|
+
let minX = valuesX.length ? Math.min(...valuesX) : 0;
|
|
367
|
+
let maxX = valuesX.length ? Math.max(...valuesX) : 1;
|
|
368
|
+
let minY = valuesY.length ? Math.min(...valuesY) : 0;
|
|
369
|
+
let maxY = valuesY.length ? Math.max(...valuesY) : 1;
|
|
370
|
+
if (williams) { minX = 0; maxX = Math.max(maxX, (points[0]?.hStar || 0) * 1.2); minY = Math.min(minY, -3.5); maxY = Math.max(maxY, 3.5); }
|
|
371
|
+
else if (plotType === "outlier") { const limit = Math.max(2.5, Math.abs(minX) + .5, Math.abs(maxX) + .5); minX = minY = -limit; maxX = maxY = limit; }
|
|
372
|
+
else { const low = Math.min(minX, minY); const high = Math.max(maxX, maxY); minX = minY = low; maxX = maxY = high; }
|
|
373
|
+
const paddingX = (maxX - minX || 1) * .07;
|
|
374
|
+
const paddingY = (maxY - minY || 1) * .07;
|
|
375
|
+
minX -= paddingX; maxX += paddingX; minY -= paddingY; maxY += paddingY;
|
|
376
|
+
const left = 62, top = 28, width = 576, height = 340;
|
|
377
|
+
const px = value => left + (value - minX) / (maxX - minX) * width;
|
|
378
|
+
const py = value => top + height - (value - minY) / (maxY - minY) * height;
|
|
379
|
+
for (let tick = 0; tick <= 4; tick++) {
|
|
380
|
+
const x = left + width * tick / 4;
|
|
381
|
+
const y = top + height * tick / 4;
|
|
382
|
+
drawLine(svg, x, top, x, top + height, true);
|
|
383
|
+
drawLine(svg, left, y, left + width, y, true);
|
|
384
|
+
svg.appendChild(svgElement("text", { x, y: top + height + 19, "text-anchor": "middle", class: "plot-tick" }, (minX + (maxX - minX) * tick / 4).toPrecision(3)));
|
|
385
|
+
svg.appendChild(svgElement("text", { x: left - 9, y: y + 4, "text-anchor": "end", class: "plot-tick" }, (maxY - (maxY - minY) * tick / 4).toPrecision(3)));
|
|
386
|
+
}
|
|
387
|
+
if (williams) {
|
|
388
|
+
for (const bound of [-3, 3]) drawLine(svg, left, py(bound), left + width, py(bound), true);
|
|
389
|
+
if (points[0]?.hStar !== null && Number.isFinite(points[0]?.hStar)) drawLine(svg, px(points[0].hStar), top, px(points[0].hStar), top + height, true);
|
|
390
|
+
} else if (plotType === "observed") drawLine(svg, px(Math.max(minX, minY)), py(Math.max(minX, minY)), px(Math.min(maxX, maxY)), py(Math.min(maxX, maxY)), true);
|
|
391
|
+
else {
|
|
392
|
+
for (const bound of [-threshold, threshold]) {
|
|
393
|
+
drawLine(svg, px(bound), top, px(bound), top + height, true);
|
|
394
|
+
drawLine(svg, left, py(bound), left + width, py(bound), true);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
drawLine(svg, left, top + height, left + width, top + height);
|
|
398
|
+
drawLine(svg, left, top, left, top + height);
|
|
399
|
+
const xLabel = williams ? "Leverage" : plotType === "outlier" ? "SD of the errors" : plotData.target;
|
|
400
|
+
const yLabel = williams ? "Standardized residual" : plotType === "outlier" ? "SD of the errors" : `Predicted ${plotData.target}`;
|
|
401
|
+
svg.appendChild(svgElement("text", { x: left + width / 2, y: 423, "text-anchor": "middle", class: "plot-axis" }, xLabel));
|
|
402
|
+
svg.appendChild(svgElement("text", { transform: "translate(17 198) rotate(-90)", "text-anchor": "middle", class: "plot-axis" }, yLabel));
|
|
403
|
+
const legend = document.getElementById("plot-legend");
|
|
404
|
+
legend.replaceChildren();
|
|
405
|
+
for (const group of [...new Set(coordinates.map(point => point.group))]) {
|
|
406
|
+
const button = document.createElement("button");
|
|
407
|
+
button.type = "button";
|
|
408
|
+
button.className = `legend-button ${hiddenGroups.has(group) ? "muted" : ""}`;
|
|
409
|
+
button.dataset.legendGroup = group;
|
|
410
|
+
button.textContent = `${group === "CV" ? plotData.cvLabel : group} (${coordinates.filter(point => point.group === group).length})`;
|
|
411
|
+
button.style.setProperty("--series-color", colors[group] || colors.Data);
|
|
412
|
+
legend.appendChild(button);
|
|
413
|
+
}
|
|
414
|
+
for (const point of coordinates) {
|
|
415
|
+
if (hiddenGroups.has(point.group)) continue;
|
|
416
|
+
if (!williams && plotType === "observed" && point.sd !== null) {
|
|
417
|
+
drawLine(svg, px(point.x), py(point.y - point.sd), px(point.x), py(point.y + point.sd));
|
|
418
|
+
}
|
|
419
|
+
const circle = svgElement("circle", { cx: px(point.x), cy: py(point.y), r: 5.5,
|
|
420
|
+
fill: colors[point.group] || colors.Data, stroke: "#000", "stroke-width": 0.8,
|
|
421
|
+
class: "plot-point", tabindex: 0, "aria-label": `${point.label}: ${point.x}, ${point.y}` });
|
|
422
|
+
circle.addEventListener("mouseenter", () => inspectPoint(point, williams));
|
|
423
|
+
circle.addEventListener("focus", () => inspectPoint(point, williams));
|
|
424
|
+
circle.addEventListener("click", () => inspectPoint(point, williams));
|
|
425
|
+
svg.appendChild(circle);
|
|
426
|
+
}
|
|
427
|
+
if (!coordinates.length) svg.appendChild(svgElement("text", { x: 340, y: 200, "text-anchor": "middle", class: "plot-axis" }, "No measured points are available for this plot"));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function loadPlot() {
|
|
431
|
+
if (!bridge || !document.getElementById("plot-file").options.length) return;
|
|
432
|
+
const token = ++requestId;
|
|
433
|
+
errorFor("plot", "");
|
|
434
|
+
bridge.getPlotData(Number(document.getElementById("plot-file").value), payload => {
|
|
435
|
+
if (token !== requestId) return;
|
|
436
|
+
const result = JSON.parse(payload);
|
|
437
|
+
if (result.error) return errorFor("plot", result.error);
|
|
438
|
+
plotData = result;
|
|
439
|
+
hiddenGroups.clear();
|
|
440
|
+
inspectedPoint = "";
|
|
441
|
+
document.getElementById("plot-point-details").textContent = "Hover over or select a point.";
|
|
442
|
+
document.getElementById("plot-molecule").hidden = true;
|
|
443
|
+
drawPlot();
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
document.addEventListener("click", event => {
|
|
448
|
+
if (event.target.closest("[data-close-result]")) return open(null);
|
|
449
|
+
if (event.target.id === "histogram-close") {
|
|
450
|
+
document.getElementById("prediction-histogram").hidden = true;
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
const histogram = event.target.closest("[data-histogram]");
|
|
454
|
+
if (histogram) return loadHistogram(histogram.dataset.histogram);
|
|
455
|
+
const sort = event.target.closest("[data-sort-column]");
|
|
456
|
+
if (sort) {
|
|
457
|
+
descending = sortColumn === sort.dataset.sortColumn && !descending;
|
|
458
|
+
sortColumn = sort.dataset.sortColumn;
|
|
459
|
+
predictionPage = 0;
|
|
460
|
+
return loadPredictions();
|
|
461
|
+
}
|
|
462
|
+
const mode = event.target.closest("[data-plot-type]");
|
|
463
|
+
if (mode) {
|
|
464
|
+
plotType = mode.dataset.plotType;
|
|
465
|
+
document.querySelectorAll("[data-plot-type]").forEach(button => button.classList.toggle("active", button === mode));
|
|
466
|
+
return drawPlot();
|
|
467
|
+
}
|
|
468
|
+
const legend = event.target.closest("[data-legend-group]");
|
|
469
|
+
if (legend) {
|
|
470
|
+
if (hiddenGroups.has(legend.dataset.legendGroup)) hiddenGroups.delete(legend.dataset.legendGroup);
|
|
471
|
+
else hiddenGroups.add(legend.dataset.legendGroup);
|
|
472
|
+
return drawPlot();
|
|
473
|
+
}
|
|
474
|
+
if (event.target.id === "report-previous") { reportPage -= 1; return loadReport(); }
|
|
475
|
+
if (event.target.id === "report-next") { reportPage += 1; return loadReport(); }
|
|
476
|
+
if (event.target.id === "prediction-previous") { predictionPage -= 1; return loadPredictions(); }
|
|
477
|
+
if (event.target.id === "prediction-next") { predictionPage += 1; return loadPredictions(); }
|
|
478
|
+
});
|
|
479
|
+
document.addEventListener("change", event => {
|
|
480
|
+
if (event.target.id === "report-file") { reportPage = 0; return loadReport(); }
|
|
481
|
+
if (event.target.id === "report-zoom") return loadReport();
|
|
482
|
+
if (event.target.id === "prediction-file") { resetPredictionSelection(); return loadPredictions(); }
|
|
483
|
+
if (event.target.id === "plot-file") return loadPlot();
|
|
484
|
+
});
|
|
485
|
+
let searchTimer;
|
|
486
|
+
document.getElementById("prediction-search").addEventListener("input", () => {
|
|
487
|
+
clearTimeout(searchTimer);
|
|
488
|
+
predictionPage = 0;
|
|
489
|
+
searchTimer = setTimeout(loadPredictions, 200);
|
|
490
|
+
});
|
|
491
|
+
document.querySelector(".prediction-insights").addEventListener("toggle", event => {
|
|
492
|
+
if (event.target.open) loadDiagnostics();
|
|
493
|
+
});
|
|
494
|
+
document.querySelector(".prediction-statistics").addEventListener("toggle", event => {
|
|
495
|
+
if (event.target.open && predictionNumeric) renderPredictionStatistics(predictionNumeric);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
window.easyrobResults = { connect: value => { bridge = value; }, render, open };
|
|
499
|
+
})();
|
|
Binary file
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Apply the web workspace palette to native modal dialogs."""
|
|
2
|
+
|
|
3
|
+
from PySide6.QtCore import Qt
|
|
4
|
+
from PySide6.QtWidgets import QDialog, QDialogButtonBox, QFileDialog, QMessageBox
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
_DIALOG_STYLE = """
|
|
8
|
+
QDialog, QMessageBox, QInputDialog {
|
|
9
|
+
background-color: #f8f5fc;
|
|
10
|
+
color: #30213f;
|
|
11
|
+
font-size: 12px;
|
|
12
|
+
}
|
|
13
|
+
QDialog QLabel, QMessageBox QLabel, QInputDialog QLabel {
|
|
14
|
+
color: #3e2a52;
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
}
|
|
17
|
+
QDialog QPushButton, QMessageBox QPushButton, QInputDialog QPushButton {
|
|
18
|
+
min-width: 74px;
|
|
19
|
+
min-height: 27px;
|
|
20
|
+
padding: 6px 13px;
|
|
21
|
+
border: 1px solid #d2bde6;
|
|
22
|
+
border-radius: 8px;
|
|
23
|
+
background-color: #eee5f7;
|
|
24
|
+
color: #523477;
|
|
25
|
+
font-weight: 600;
|
|
26
|
+
}
|
|
27
|
+
QDialog QPushButton:hover, QMessageBox QPushButton:hover, QInputDialog QPushButton:hover {
|
|
28
|
+
background-color: #e2d1f1;
|
|
29
|
+
}
|
|
30
|
+
QDialog QPushButton:default, QMessageBox QPushButton:default, QInputDialog QPushButton:default {
|
|
31
|
+
background-color: #7340aa;
|
|
32
|
+
border-color: #7340aa;
|
|
33
|
+
color: white;
|
|
34
|
+
}
|
|
35
|
+
QDialog QLineEdit, QDialog QComboBox, QDialog QTextEdit, QDialog QPlainTextEdit {
|
|
36
|
+
border: 1px solid #d8c9e6;
|
|
37
|
+
border-radius: 8px;
|
|
38
|
+
padding: 6px;
|
|
39
|
+
background-color: white;
|
|
40
|
+
color: #342548;
|
|
41
|
+
selection-background-color: #c9a7e8;
|
|
42
|
+
}
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def style_dialog(dialog):
|
|
47
|
+
"""Style a modal once, preserving its existing buttons and return values."""
|
|
48
|
+
if not isinstance(dialog, QDialog) or isinstance(dialog, QFileDialog):
|
|
49
|
+
return
|
|
50
|
+
if dialog.property("easyrobModernDialog"):
|
|
51
|
+
return
|
|
52
|
+
dialog.setProperty("easyrobModernDialog", True)
|
|
53
|
+
dialog.setStyleSheet(dialog.styleSheet() + "\n" + _DIALOG_STYLE)
|
|
54
|
+
if isinstance(dialog, QMessageBox):
|
|
55
|
+
button_box = dialog.findChild(QDialogButtonBox)
|
|
56
|
+
if button_box is not None:
|
|
57
|
+
buttons = button_box.buttons()
|
|
58
|
+
for button in buttons:
|
|
59
|
+
text_width = button.fontMetrics().horizontalAdvance(button.text())
|
|
60
|
+
button.setMinimumWidth(text_width + 36)
|
|
61
|
+
button.setMinimumHeight(40)
|
|
62
|
+
if len(buttons) >= 3:
|
|
63
|
+
button_box.setOrientation(Qt.Vertical)
|
|
64
|
+
dialog.adjustSize()
|