Skip to content

Commit

Permalink
Fix broken ert test_run
Browse files Browse the repository at this point in the history
The commit 4013764 introduced a regression such that `ert test_run`
would fail on any configs that sets a queue system other than "local".

This was due to the function `create_local_copy()` not having been
updated to yield the correct QueueOptions object after refactoring.
  • Loading branch information
berland committed Aug 22, 2024
1 parent ef64736 commit 2039944
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/ert/config/queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class QueueConfig:
max_submit: int = 1
queue_system: QueueSystem = QueueSystem.LOCAL
queue_options: QueueOptions = field(default_factory=QueueOptions)
queue_options_test_run: QueueOptions = field(default_factory=LocalQueueOptions)
stop_long_running: bool = False

@no_type_check
Expand Down Expand Up @@ -299,6 +300,7 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig:
)

queue_options = _all_validated_queue_options[selected_queue_system]
queue_options_test_run = _all_validated_queue_options[QueueSystem.LOCAL]
queue_options.add_global_queue_options(config_dict)

if queue_options.project_code is None:
Expand Down Expand Up @@ -353,6 +355,7 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig:
max_submit,
selected_queue_system,
queue_options,
queue_options_test_run,
stop_long_running=stop_long_running,
)

Expand All @@ -362,7 +365,8 @@ def create_local_copy(self) -> QueueConfig:
self.realization_memory,
self.max_submit,
QueueSystem.LOCAL,
self.queue_options,
self.queue_options_test_run,
self.queue_options_test_run,
stop_long_running=self.stop_long_running,
)

Expand Down
7 changes: 7 additions & 0 deletions tests/integration_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def test_bad_config_error_message(tmp_path):
run_cli(TEST_RUN_MODE, "--disable-monitor", str(tmp_path / "test.ert"))


def test_test_run_on_lsf_configuration_works_with_no_errors(tmp_path):
(tmp_path / "test.ert").write_text(
"NUM_REALIZATIONS 1\nQUEUE_SYSTEM LSF", encoding="utf-8"
)
run_cli(TEST_RUN_MODE, "--disable-monitor", str(tmp_path / "test.ert"))


@pytest.mark.parametrize(
"mode",
[
Expand Down
4 changes: 3 additions & 1 deletion tests/unit_tests/config/test_queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
def test_create_local_copy_is_a_copy_with_local_queue_system():
queue_config = QueueConfig(queue_system=QueueSystem.LSF)
assert queue_config.queue_system == QueueSystem.LSF
assert queue_config.create_local_copy().queue_system == QueueSystem.LOCAL
local_queue_config = queue_config.create_local_copy()
assert local_queue_config.queue_system == QueueSystem.LOCAL
assert isinstance(local_queue_config.queue_options, LocalQueueOptions)


@pytest.mark.parametrize("value", [True, False])
Expand Down

0 comments on commit 2039944

Please sign in to comment.