Skip to content

Commit

Permalink
Introduce new initial state, FORWARD_MODEL_STATE_INIT, for forward mo…
Browse files Browse the repository at this point in the history
…del steps

- Introduces an initial state for the forward model steps
 equal to "pending" to differentiate from the starting state
- Changes the starting state from "pending" to "running" since
 we already start populating the duration field in the gui.
  • Loading branch information
larsevj committed Jan 29, 2025
1 parent 79bdf82 commit 1e8cb1c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/ert/ensemble_evaluator/_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ENSEMBLE_STATE_STARTED,
ENSEMBLE_STATE_STOPPED,
ENSEMBLE_STATE_UNKNOWN,
FORWARD_MODEL_STATE_START,
FORWARD_MODEL_STATE_INIT,
REALIZATION_STATE_WAITING,
)

Expand Down Expand Up @@ -126,7 +126,7 @@ def _create_snapshot(self) -> EnsembleSnapshot:
)
for index, fm_step in enumerate(real.fm_steps):
realization["fm_steps"][str(index)] = FMStepSnapshot(
status=FORWARD_MODEL_STATE_START,
status=FORWARD_MODEL_STATE_INIT,
index=str(index),
name=fm_step.name,
)
Expand Down
2 changes: 1 addition & 1 deletion src/ert/ensemble_evaluator/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def update_from_event(
fm_idx = (event.real, fm_step_id)
self._fm_step_snapshots[fm_idx].update(
FMStepSnapshot(
status=state.FORWARD_MODEL_STATE_START,
status=state.FORWARD_MODEL_STATE_INIT,
start_time=None,
end_time=None,
current_memory_usage=None,
Expand Down
6 changes: 4 additions & 2 deletions src/ert/ensemble_evaluator/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
REALIZATION_STATE_UNKNOWN,
)

FORWARD_MODEL_STATE_START: Final = "Pending"
FORWARD_MODEL_STATE_INIT: Final = "Pending"
FORWARD_MODEL_STATE_START: Final = "Running"
FORWARD_MODEL_STATE_RUNNING: Final = "Running"
FORWARD_MODEL_STATE_FINISHED: Final = "Finished"
FORWARD_MODEL_STATE_FAILURE: Final = "Failed"
Expand All @@ -46,7 +47,8 @@
}

FORWARD_MODEL_STATE_TO_COLOR: Final = {
str(FORWARD_MODEL_STATE_START): COLOR_PENDING,
str(FORWARD_MODEL_STATE_INIT): COLOR_PENDING,
str(FORWARD_MODEL_STATE_START): COLOR_RUNNING,
str(FORWARD_MODEL_STATE_RUNNING): COLOR_RUNNING,
str(FORWARD_MODEL_STATE_FINISHED): COLOR_FINISHED,
str(FORWARD_MODEL_STATE_FAILURE): COLOR_FAILED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ert.config import ForwardModelStep, QueueConfig, QueueSystem
from ert.ensemble_evaluator._ensemble import LegacyEnsemble, Realization
from ert.ensemble_evaluator.state import FORWARD_MODEL_STATE_INIT


@pytest.mark.parametrize("active_real", [True, False])
Expand All @@ -29,3 +30,8 @@ def test_build_ensemble(active_real):

real = ensemble.reals[0]
assert real.active == active_real
if active_real:
assert (
ensemble.snapshot.get_fm_step("2", "0").get("status")
== FORWARD_MODEL_STATE_INIT
)
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/gui/model/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_snapshot_model_data_intact_on_full_update(full_snapshot, fail_snapshot)
model._add_snapshot(SnapshotModel.prerender(full_snapshot), "0")

first_real = model.index(0, 0, model.index(0, 0))
assert first_real.internalPointer().children["0"].data["status"] == "Pending"
assert first_real.internalPointer().children["0"].data["status"] == "Running"
# Update with a different snapshot, -- data should change accordingly
model._add_snapshot(SnapshotModel.prerender(fail_snapshot), "0")
first_real = model.index(0, 0, model.index(0, 0))
Expand Down
4 changes: 2 additions & 2 deletions tests/ert/unit_tests/test_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ert.ensemble_evaluator.state import (
FORWARD_MODEL_STATE_FAILURE,
FORWARD_MODEL_STATE_FINISHED,
FORWARD_MODEL_STATE_START,
FORWARD_MODEL_STATE_INIT,
REALIZATION_STATE_FINISHED,
)
from ert.mode_definitions import (
Expand Down Expand Up @@ -133,7 +133,7 @@ def check_expression(original, path_expression, expected, msg_start):
"reals.'0'.fm_steps.'0'.status",
FORWARD_MODEL_STATE_FAILURE,
),
("0", "reals.'0'.fm_steps.'1'.status", FORWARD_MODEL_STATE_START),
("0", "reals.'0'.fm_steps.'1'.status", FORWARD_MODEL_STATE_INIT),
(
".*",
"reals.'1'.fm_steps.*.status",
Expand Down

0 comments on commit 1e8cb1c

Please sign in to comment.