Skip to content

Commit

Permalink
Removed done_realization and updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Jun 14, 2024
1 parent 7660539 commit 7ac6cdd
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 103 deletions.
1 change: 0 additions & 1 deletion src/ert/ensemble_evaluator/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class _UpdateEvent:
current_phase: int
total_phases: int
progress: float
done_realizations: int
realization_count: int
status_count: Dict[str, int]
iteration: int
Expand Down
2 changes: 2 additions & 0 deletions src/ert/gui/simulation/view/progress_widget.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any

from qtpy.QtGui import QColor
Expand Down
14 changes: 4 additions & 10 deletions src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def checkHaveSufficientRealizations(
f"MIN_REALIZATIONS to allow (more) failures in your experiments."
)

def _current_status(self) -> tuple[dict[str, int], int, float, int]:
def _current_status(self) -> tuple[dict[str, int], float, int]:
current_iter = max(list(self._iter_snapshot.keys()))
done_realizations = 0
all_realizations = self._iter_snapshot[current_iter].reals
Expand All @@ -447,7 +447,7 @@ def _current_status(self) -> tuple[dict[str, int], int, float, int]:
else realization_progress
)

return status, done_realizations, current_progress, realization_count
return status, current_progress, realization_count

def send_end_event(self) -> None:
self.send_event(
Expand All @@ -462,16 +462,13 @@ def send_snapshot_event(self, event: CloudEvent) -> None:
iter_ = event.data["iter"]
snapshot = Snapshot(event.data)
self._iter_snapshot[iter_] = snapshot
status, done_realizations, current_progress, realization_count = (
self._current_status()
)
status, current_progress, realization_count = self._current_status()
self.send_event(
FullSnapshotEvent(
phase_name=self.getPhaseName(),
current_phase=self.currentPhase(),
total_phases=self.phaseCount(),
progress=current_progress,
done_realizations=done_realizations,
realization_count=realization_count,
status_count=status,
iteration=iter_,
Expand All @@ -487,16 +484,13 @@ def send_snapshot_event(self, event: CloudEvent) -> None:
)
partial = PartialSnapshot(self._iter_snapshot[iter_]).from_cloudevent(event)
self._iter_snapshot[iter_].merge_event(partial)
status, done_realizations, current_progress, realization_count = (
self._current_status()
)
status, current_progress, realization_count = self._current_status()
self.send_event(
SnapshotUpdateEvent(
phase_name=self.getPhaseName(),
current_phase=self.currentPhase(),
total_phases=self.phaseCount(),
progress=current_progress,
done_realizations=done_realizations,
realization_count=realization_count,
status_count=status,
iteration=iter_,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests/cli/test_cli_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def test_print_progress():
current_phase=0,
total_phases=2,
progress=0.5,
realization_count=100,
status_count={"Finished": 50, "Waiting": 50},
iteration=0,
)

Expand Down
87 changes: 0 additions & 87 deletions tests/unit_tests/gui/model/test_progress_proxy.py

This file was deleted.

37 changes: 32 additions & 5 deletions tests/unit_tests/gui/simulation/test_run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.5,
realization_count=4,
status_count={"Running": 2, "Unknown": 2},
iteration=0,
),
FullSnapshotEvent(
Expand All @@ -133,6 +135,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.5,
realization_count=4,
status_count={"Running": 2, "Unknown": 2},
iteration=1,
),
EndEvent(failed=False, failed_msg=""),
Expand Down Expand Up @@ -175,6 +179,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.25,
realization_count=4,
status_count={"Pending": 1, "Unknown": 3},
iteration=0,
),
SnapshotUpdateEvent(
Expand All @@ -187,6 +193,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.5,
realization_count=4,
status_count={"Finished": 1, "Unknown": 3},
iteration=0,
),
EndEvent(failed=False, failed_msg=""),
Expand All @@ -213,6 +221,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.25,
realization_count=4,
status_count={"Pending": 1, "Unknown": 3},
iteration=0,
),
SnapshotUpdateEvent(
Expand All @@ -225,6 +235,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.5,
realization_count=4,
status_count={"Finished": 1, "Unknown": 3},
iteration=0,
),
EndEvent(failed=False, failed_msg=""),
Expand Down Expand Up @@ -255,12 +267,13 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.25,
realization_count=4,
status_count={"Pending": 2, "Unknown": 2},
iteration=0,
),
SnapshotUpdateEvent(
partial_snapshot=PartialSnapshot(
SnapshotBuilder()
# .add_step(status=state.STEP_STATE_SUCCESS)
.add_forward_model(
forward_model_id="0",
index="0",
Expand All @@ -273,6 +286,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.5,
realization_count=4,
status_count={"Finished": 1, "Running": 1, "Unknown": 2},
iteration=0,
),
SnapshotUpdateEvent(
Expand All @@ -290,6 +305,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.5,
realization_count=4,
status_count={"Pending": 1, "Failed": 1, "Unknown": 2},
iteration=0,
),
EndEvent(failed=False, failed_msg=""),
Expand All @@ -314,6 +331,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.25,
realization_count=4,
status_count={"Pending": 1, "Unknown": 3},
iteration=0,
),
FullSnapshotEvent(
Expand All @@ -331,6 +350,8 @@ def test_large_snapshot(
current_phase=0,
total_phases=1,
progress=0.5,
realization_count=4,
status_count={"Pending": 1, "Unknown": 3},
iteration=1,
),
EndEvent(failed=False, failed_msg=""),
Expand Down Expand Up @@ -426,6 +447,8 @@ def test_that_run_dialog_can_be_closed_while_file_plot_is_open(qtbot: QtBot, sto
current_phase=0,
total_phases=1,
progress=0.25,
realization_count=4,
status_count={"Pending": 1, "Unknown": 3},
iteration=0,
),
SnapshotUpdateEvent(
Expand All @@ -435,8 +458,8 @@ def test_that_run_dialog_can_be_closed_while_file_plot_is_open(qtbot: QtBot, sto
forward_model_id="0",
index="0",
status=state.FORWARD_MODEL_STATE_RUNNING,
current_memory_usage=45000,
max_memory_usage=55000,
current_memory_usage="45000",
max_memory_usage="55000",
name="job_0",
)
.build(["0"], status=state.REALIZATION_STATE_RUNNING)
Expand All @@ -445,6 +468,8 @@ def test_that_run_dialog_can_be_closed_while_file_plot_is_open(qtbot: QtBot, sto
current_phase=0,
total_phases=1,
progress=0.5,
realization_count=4,
status_count={"Running": 1, "Unknown": 3},
iteration=0,
),
SnapshotUpdateEvent(
Expand All @@ -455,15 +480,17 @@ def test_that_run_dialog_can_be_closed_while_file_plot_is_open(qtbot: QtBot, sto
index="0",
status=state.FORWARD_MODEL_STATE_FINISHED,
name="job_0",
current_memory_usage=50000,
max_memory_usage=60000,
current_memory_usage="50000",
max_memory_usage="60000",
)
.build(["0"], status=state.REALIZATION_STATE_FINISHED)
),
phase_name="Foo",
current_phase=0,
total_phases=1,
progress=1,
realization_count=4,
status_count={"Finished": 4},
iteration=0,
),
EndEvent(failed=False, failed_msg=""),
Expand Down

0 comments on commit 7ac6cdd

Please sign in to comment.