Skip to content

Commit

Permalink
Do warning if another queue system is configured
Browse files Browse the repository at this point in the history
  • Loading branch information
xjules committed Nov 3, 2023
1 parent 515e6af commit f6a9859
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ert/config/queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig:
if queue_system != selected_queue_system:
warnings.warn(
ConfigWarning.with_context(
f"Setting '{option_name}'for {queue_system.name} but "
f"{selected_queue_system.name} is selected. ",
f"Setting '{option_name}' for {queue_system.name} but "
f"{selected_queue_system.name} is selected.",
option_name,
),
stacklevel=1,
Expand Down
22 changes: 21 additions & 1 deletion tests/unit_tests/config/test_queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
import pytest
from hypothesis import given

from ert.config import ConfigValidationError, ErtConfig, QueueConfig, QueueSystem
from ert.config import (
ConfigValidationError,
ConfigWarning,
ErtConfig,
QueueConfig,
QueueSystem,
)
from ert.job_queue import Driver


Expand Down Expand Up @@ -192,3 +198,17 @@ def test_wrong_config_option_types(queue_system, queue_option, queue_value, err_

with pytest.raises(ConfigValidationError, match=err_msg):
ErtConfig.from_file(filename)


@pytest.mark.usefixtures("use_tmpdir")
def test_that_configuring_another_queue_system_gives_warning():
filename = "config.ert"
with open(filename, "w", encoding="utf-8") as f:
f.write("NUM_REALIZATIONS 1\n")
f.write(f"QUEUE_SYSTEM LSF\n")
f.write(f"QUEUE_OPTION SLURM SQUEUE_TIMEOUT 2\n")

with pytest.warns(
ConfigWarning, match="Setting 'SQUEUE_TIMEOUT' for SLURM but LSF is selected."
):
ErtConfig.from_file(filename)

0 comments on commit f6a9859

Please sign in to comment.