Skip to content

Commit

Permalink
Remove copy debug info button
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Jan 28, 2025
1 parent b96b543 commit 8a420e8
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 171 deletions.
75 changes: 1 addition & 74 deletions src/ert/gui/simulation/experiment_panel.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
from __future__ import annotations

import os
import platform
from collections import OrderedDict
from dataclasses import fields
from datetime import datetime
from pathlib import Path
from queue import SimpleQueue
from typing import TYPE_CHECKING, Any

Expand All @@ -25,17 +20,9 @@
QWidget,
)

import ert.shared
from ert.gui.ertnotifier import ErtNotifier
from ert.run_models import BaseRunModel, SingleTestRun, StatusEvents, create_model
from ert.shared.status.utils import (
byte_with_unit,
format_running_time,
get_ert_memory_usage,
)
from ert.trace import get_trace_id
from ert.run_models import BaseRunModel, StatusEvents, create_model

from ...config.queue_config import LocalQueueOptions
from ..summarypanel import SummaryPanel
from .combobox_with_description import QComboBoxWithDescription
from .ensemble_experiment_panel import EnsembleExperimentPanel
Expand Down Expand Up @@ -321,9 +308,6 @@ def run_experiment(self) -> None:
output_path=self.config.analysis_config.log_path,
)
self.experiment_started.emit(self._dialog)
self._dialog.produce_clipboard_debug_info.connect(
self.populate_clipboard_debug_info
)
self._simulation_done = False
self.run_button.setEnabled(self._simulation_done)
self._dialog.run_experiment()
Expand All @@ -349,60 +333,3 @@ def validationStatusChanged(self) -> None:
self.run_button.setEnabled(
self._simulation_done and widget.isConfigurationValid()
)

def populate_clipboard_debug_info(self) -> None:
kv = {"**Platform**": "", ":-----": ":-----"}
kv["Date"] = datetime.now().isoformat(" ", "seconds")
kv["OS"] = (
platform.system() + " " + platform.release() + " " + platform.machine()
)
kv["Hostname"] = ert.shared.get_machine_name()
kv["Komodo release"] = os.environ.get("KOMODO_RELEASE", "")
kv["Python version"] = platform.python_version()

kv["**Ensemble**"] = ""
queue_system = self.config.queue_config.queue_system
kv["Queue"] = queue_system.name.capitalize()
kv["Simulation mode"] = self.get_current_experiment_type().name()
kv["Config file"] = str(Path(self._config_file).absolute())
kv["Storage path"] = self.config.ens_path
kv["Run path"] = str(self.config.model_config.runpath_format_string)
kv["Ensemble size"] = str(self.config.model_config.num_realizations)

if self.config.queue_config.realization_memory > 0:
kv["Realization memory"] = byte_with_unit(
self.config.queue_config.realization_memory
)

if self.config.queue_config.max_submit > 1:
kv["Max submit"] = str(self.config.queue_config.max_submit)
if self.config.queue_config.stop_long_running:
kv["Stop long running"] = str(self.config.queue_config.stop_long_running)

queue_opts = self.config.queue_config.queue_options

if isinstance(self.get_current_experiment_type(), SingleTestRun):
queue_opts = LocalQueueOptions(max_running=1)

for field in fields(queue_opts):
field_value = getattr(queue_opts, field.name)
if field_value is not None:
kv[field.name.replace("_", " ").capitalize()] = str(field_value)

kv["**Status**"] = ""
kv["Trace ID"] = get_trace_id()
kv["Running time"] = (
format_running_time(self._model.get_runtime()).split(":")[1].strip()
)
kv["Ert max memory"] = byte_with_unit(get_ert_memory_usage())
kv["Forward model max memory"] = byte_with_unit(
self._model.get_memory_consumption()
)

for status, count in self._model.get_current_status().items():
kv[status] = str(count)

output = create_md_table(kv, "")
clipboard = QApplication.clipboard()
if clipboard:
clipboard.setText(output)
33 changes: 0 additions & 33 deletions src/ert/gui/simulation/run_dialog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import logging
from collections.abc import Callable
from pathlib import Path
from queue import SimpleQueue
from typing import cast
Expand Down Expand Up @@ -167,7 +166,6 @@ def mouseMoveEvent(self, e: QMouseEvent | None) -> None:

class RunDialog(QFrame):
simulation_done = Signal(bool, str)
produce_clipboard_debug_info = Signal()
progress_update_event = Signal(dict, int)
_RUN_TIME_POLL_RATE = 1000

Expand Down Expand Up @@ -229,10 +227,6 @@ def __init__(
self.restart_button = QPushButton("Rerun failed")
self.restart_button.setHidden(True)

self.copy_debug_info_button = CopyDebugInfoButton(
on_click=self.produce_clipboard_debug_info.emit
)

size = 20
spin_movie = QMovie("img:loading.gif")
spin_movie.setSpeed(60)
Expand All @@ -251,7 +245,6 @@ def __init__(
button_layout.addStretch()
button_layout.addWidget(self.disk_space)
button_layout.addStretch()
button_layout.addWidget(self.copy_debug_info_button)
button_layout.addWidget(self.kill_button)
button_layout.addWidget(self.restart_button)

Expand Down Expand Up @@ -529,32 +522,6 @@ def restart_failed_realizations(self) -> None:
self.run_experiment(restart=True)


class CopyDebugInfoButton(QPushButton):
_initial_text = "Copy Debug Info"
_clicked_text = "Copied..."

def __init__(self, on_click: Callable[[], None], time_to_alternate: int = 1000):
QPushButton.__init__(self, CopyDebugInfoButton._initial_text)
self.setToolTip("Copies useful information to clipboard")
self.setObjectName("copy_debug_info_button")
self.setFixedWidth(140)
self.time_to_alternate = time_to_alternate

def alternate_button_text_on_click_and_call_callback() -> None:
self._alternate_button_text()
on_click()
QTimer.singleShot(self.time_to_alternate, self._alternate_button_text)

self.clicked.connect(alternate_button_text_on_click_and_call_callback)

def _alternate_button_text(self) -> None:
self.setText(
CopyDebugInfoButton._initial_text
if self.text() == CopyDebugInfoButton._clicked_text
else CopyDebugInfoButton._clicked_text
)


# Cannot use a non-static method here as
# it is called when the object is destroyed
# https://stackoverflow.com/questions/16842955
Expand Down
23 changes: 0 additions & 23 deletions tests/ert/unit_tests/gui/ertwidgets/test_copy_debug_info_button.py

This file was deleted.

41 changes: 0 additions & 41 deletions tests/ert/unit_tests/gui/simulation/test_run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pytest
from PyQt6.QtCore import Qt, QTimer
from PyQt6.QtWidgets import (
QApplication,
QComboBox,
QDialogButtonBox,
QLabel,
Expand Down Expand Up @@ -591,46 +590,6 @@ def handle_error_dialog(run_dialog):
qtbot.waitUntil(lambda: run_dialog.is_simulation_done() == True, timeout=100000)


@pytest.mark.integration_test
@pytest.mark.usefixtures("use_tmpdir")
def test_that_debug_info_button_provides_data_in_clipboard(qtbot: QtBot, storage):
config_file = "minimal_config.ert"
with open(config_file, "w", encoding="utf-8") as f:
f.write("NUM_REALIZATIONS 1")
args_mock = Mock()
args_mock.config = config_file

ert_config = ErtConfig.from_file(config_file)
with StorageService.init_service(
project=os.path.abspath(ert_config.ens_path),
):
gui = _setup_main_window(ert_config, args_mock, GUILogHandler(), storage)
experiment_panel = gui.findChild(ExperimentPanel)
assert experiment_panel

run_experiment = experiment_panel.findChild(QToolButton, name="run_experiment")
assert run_experiment

qtbot.mouseClick(run_experiment, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: gui.findChild(RunDialog) is not None, timeout=5000)
run_dialog = gui.findChild(RunDialog)
assert run_dialog
qtbot.waitUntil(lambda: run_dialog.is_simulation_done() == True, timeout=100000)
copy_debug_info_button = gui.findChild(QPushButton, "copy_debug_info_button")
assert copy_debug_info_button
qtbot.mouseClick(copy_debug_info_button, Qt.MouseButton.LeftButton)

clipboard_text = QApplication.clipboard().text()

for keyword in [
"Single realization test-run",
"Local",
r"minimal\_config.ert",
"Trace ID",
]:
assert keyword in clipboard_text


@pytest.mark.integration_test
def test_that_stdout_and_stderr_buttons_react_to_file_content(
snake_oil_case_storage: ErtConfig, qtbot: QtBot
Expand Down

0 comments on commit 8a420e8

Please sign in to comment.