Skip to content

Commit

Permalink
Add debug info to clipboard capability
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Sep 4, 2024
1 parent 8e62a2d commit 3adcee8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/ert/gui/simulation/experiment_panel.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from __future__ import annotations

import os
import platform
from collections import OrderedDict
from datetime import datetime
from queue import SimpleQueue
from typing import TYPE_CHECKING, Any, List, Type
from typing import TYPE_CHECKING, Any, Dict, List, Type

from qtpy.QtCore import QSize, Qt, Signal
from qtpy.QtGui import QIcon, QStandardItemModel
Expand Down Expand Up @@ -270,6 +273,8 @@ def run_experiment(self) -> None:
self.parent(), # type: ignore
output_path=self.config.analysis_config.log_path,
)
dialog.produce_clipboard_debug_info.connect(self.populate_clipboard_debug_info)

self.run_button.setEnabled(False)
self.run_button.setText(EXPERIMENT_IS_RUNNING_BUTTON_MESSAGE)
dialog.run_experiment()
Expand Down Expand Up @@ -297,3 +302,34 @@ def validationStatusChanged(self) -> None:
self.run_button.text() == EXPERIMENT_READY_TO_RUN_BUTTON_MESSAGE
and widget.isConfigurationValid()
)

def create_md_table(self, kv: Dict[str, str], output: str):

Check failure on line 306 in src/ert/gui/simulation/experiment_panel.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

Function is missing a return type annotation
output += "| Key | Value |\n"
output += "|:-----|:-----|\n"
for k, v in kv.items():
output += f"| {k} | {v} |\n"
output += "\n"
return output

def populate_clipboard_debug_info(self):

Check failure on line 314 in src/ert/gui/simulation/experiment_panel.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

Function is missing a return type annotation
output = ""
kv = {}

kv["Date"] = datetime.now().strftime("%Y/%m/%d %H:%M:%S")
kv["OS"] = (
platform.system() + " " + platform.release() + " " + platform.machine()
)
kv["Hostname"] = platform.node()

for e in ["KOMODO_RELEASE"]:
if e in os.environ:
kv[e] = os.environ[e]

kv["Python Version"] = platform.python_version()
kv["Queue"] = self.config.queue_config.queue_system.name
kv["Max Running"] = self.config.queue_config.queue_options.max_running

Check failure on line 330 in src/ert/gui/simulation/experiment_panel.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

Incompatible types in assignment (expression has type "int", target has type "str")

output += self.create_md_table(kv, output)

clipboard = QApplication.clipboard()
clipboard.setText(output)

Check failure on line 335 in src/ert/gui/simulation/experiment_panel.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

Item "None" of "QClipboard | None" has no attribute "setText"
3 changes: 3 additions & 0 deletions src/ert/gui/simulation/run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def mouseMoveEvent(self, event: QMouseEvent | None) -> None:

class RunDialog(QDialog):
simulation_done = Signal(bool, str)
produce_clipboard_debug_info = Signal()
on_run_model_event = Signal(object)
_RUN_TIME_POLL_RATE = 1000

Expand Down Expand Up @@ -525,6 +526,8 @@ def keyPressEvent(self, a0: Optional[QKeyEvent]) -> None:
# so call self.close() instead
if a0 is not None and a0.key() == Qt.Key.Key_Escape:
self.close()
elif a0 is not None and a0.key() == Qt.Key.Key_F1:
self.produce_clipboard_debug_info.emit()
else:
QDialog.keyPressEvent(self, a0)

Expand Down

0 comments on commit 3adcee8

Please sign in to comment.