Skip to content

Commit bd28cf9

Browse files
committed
Resolve issues caught by unittests
1 parent f31883d commit bd28cf9

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

src/ert/_c_wrappers/enkf/model_config.py

-7
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,10 @@ def __init__(
4040
else self.DEFAULT_HISTORY_SOURCE
4141
)
4242

43-
self.has_valid_runpath = False
44-
4543
if runpath_format_string is None:
4644
self.runpath_format_string = self.DEFAULT_RUNPATH
47-
self.has_valid_runpath = True
4845
elif "%d" in runpath_format_string:
4946
self.runpath_format_string = runpath_format_string
50-
self.has_valid_runpath = True
5147
logger.warning(
5248
"RUNPATH keyword should use syntax "
5349
f"`{self.DEFAULT_RUNPATH}` "
@@ -109,9 +105,6 @@ def get_history_num_steps(self) -> int:
109105
return len(self.time_map)
110106
return 0
111107

112-
def is_valid_runpath(self) -> bool:
113-
return self.has_valid_runpath
114-
115108
def __repr__(self):
116109
return f"ModelConfig(\n{self}\n)"
117110

src/ert/gui/tools/load_results/load_results_tool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self, facade):
1414
)
1515
self.__import_widget = None
1616
self.__dialog = None
17-
self.setEnabled(self.is_valid_run_path())
17+
self.setEnabled(True)
1818

1919
def trigger(self):
2020
if self.__import_widget is None:

src/ert/libres_facade.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ def have_observations(self) -> bool:
160160
return self._enkf_main.have_observations()
161161

162162
def is_valid_runpath(self) -> bool:
163-
return self._enkf_main.getModelConfig().is_valid_runpath()
163+
iter_0_paths = set(self.get_run_paths([True] * self.get_ensemble_size(), 0))
164+
iter_1_paths = set(self.get_run_paths([True] * self.get_ensemble_size(), 1))
165+
return (
166+
len(iter_0_paths) == self.get_ensemble_size()
167+
and iter_0_paths != iter_1_paths
168+
)
164169

165170
@property
166171
def run_path(self) -> str:

tests/test_config_parsing/test_model_config.py

-3
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,19 @@ def test_default_model_config_ens_path(tmpdir):
4747
def test_default_model_config_run_path(tmpdir):
4848
mc = ModelConfig(num_realizations=1)
4949
assert mc.runpath_format_string == "simulations/realization-<IENS>/iter-<ITER>"
50-
assert mc.is_valid_runpath()
5150

5251

5352
def test_invalid_model_config_run_path(tmpdir):
5453
mc = ModelConfig(
5554
num_realizations=1, runpath_format_string="realization-no-specifier"
5655
)
5756
assert mc.runpath_format_string == "realization-no-specifier"
58-
assert not mc.is_valid_runpath()
5957

6058

6159
def test_deprecated_model_config_run_path(tmpdir):
6260
runpath = "simulations/realization-%d/iter-%d"
6361
mc = ModelConfig(num_realizations=1, runpath_format_string=runpath)
6462
assert mc.runpath_format_string == runpath
65-
assert mc.is_valid_runpath()
6663

6764

6865
@given(config_generators())

tests/unit_tests/gui/test_gui_load.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def fixture_patch_enkf_main(monkeypatch, tmp_path):
2727
mocked_enkf_main.getWorkflowList.return_value.getWorkflowNames.return_value = [
2828
"my_workflow"
2929
]
30-
mocked_enkf_main.getModelConfig.return_value.is_valid_runpath.return_value = True
3130

3231
res_config_mock = Mock()
3332
type(res_config_mock).config_path = PropertyMock(return_value=tmp_path)

tests/unit_tests/gui/tools/test_case_tool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_that_case_tool_can_copy_case_state(qtbot):
7777
@pytest.mark.parametrize(
7878
"run_path, expected",
7979
[
80-
("valid_%d", True),
80+
("valid_%d", False),
8181
("valid_%d/iter_%d", True),
8282
("invalid", False),
8383
],

0 commit comments

Comments
 (0)