diff --git a/src/everest/config/server_config.py b/src/everest/config/server_config.py index 25e9358dba5..dfdf8f15d87 100644 --- a/src/everest/config/server_config.py +++ b/src/everest/config/server_config.py @@ -1,7 +1,8 @@ import json import os +from typing import Any -from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator from ert.config.queue_config import ( LocalQueueOptions, @@ -57,6 +58,23 @@ def default_local_queue(cls, v): v["activate_script"] = ErtPluginManager().activate_script() return v + @model_validator(mode="before") + @classmethod + def check_old_config(cls, data: Any) -> Any: + if isinstance(data, dict): + queue_system = data.get("queue_system") + queue_systems = { + "lsf": LsfQueueOptions, + "torque": TorqueQueueOptions, + "slurm": SlurmQueueOptions, + "local": LocalQueueOptions, + } + if isinstance(queue_system, str) and queue_system in queue_systems: + raise ValueError( + f"Queue system configuration has changed, valid options for {queue_system} are: {list(queue_systems[queue_system].__dataclass_fields__.keys())}" + ) + return data + @staticmethod def get_server_url(output_dir: str) -> str: """Return the url of the server. diff --git a/src/everest/config/simulator_config.py b/src/everest/config/simulator_config.py index db002b19f69..ed206fa45c7 100644 --- a/src/everest/config/simulator_config.py +++ b/src/everest/config/simulator_config.py @@ -1,4 +1,13 @@ -from pydantic import BaseModel, Field, NonNegativeInt, PositiveInt, field_validator +from typing import Any + +from pydantic import ( + BaseModel, + Field, + NonNegativeInt, + PositiveInt, + field_validator, + model_validator, +) from ert.config.queue_config import ( LocalQueueOptions, @@ -78,3 +87,20 @@ def default_local_queue(cls, v): elif "activate_script" not in v and ErtPluginManager().activate_script(): v["activate_script"] = ErtPluginManager().activate_script() return v + + @model_validator(mode="before") + @classmethod + def check_old_config(cls, data: Any) -> Any: + if isinstance(data, dict): + queue_system = data.get("queue_system") + queue_systems = { + "lsf": LsfQueueOptions, + "torque": TorqueQueueOptions, + "slurm": SlurmQueueOptions, + "local": LocalQueueOptions, + } + if isinstance(queue_system, str) and queue_system in queue_systems: + raise ValueError( + f"Queue system configuration has changed, valid options for {queue_system} are: {list(queue_systems[queue_system].__dataclass_fields__.keys())}" + ) + return data diff --git a/tests/everest/test_everest_config.py b/tests/everest/test_everest_config.py index dd68888b0cc..cf27551ae63 100644 --- a/tests/everest/test_everest_config.py +++ b/tests/everest/test_everest_config.py @@ -1,7 +1,9 @@ import logging from pathlib import Path -from everest.config import EverestConfig +import pytest + +from everest.config import EverestConfig, ServerConfig, SimulatorConfig from everest.config.control_config import ControlConfig from everest.config.control_variable_config import ControlVariableConfig from everest.config.cvar_config import CVaRConfig @@ -283,3 +285,11 @@ def test_that_log_level_property_is_consistent_with_environment_log_level(): config.logging_level = lvl_str assert config.environment.log_level == lvl_str assert config.logging_level == lvl_int + + +@pytest.mark.parametrize("config_class", [SimulatorConfig, ServerConfig]) +@pytest.mark.parametrize("queue_system", ["lsf", "torque", "slurm", "local"]) +def test_removed_queue_options_init(queue_system, config_class): + config = {"queue_system": queue_system} + with pytest.raises(ValueError, match=f"valid options for {queue_system} are"): + config_class(**config) diff --git a/tests/everest/test_res_initialization.py b/tests/everest/test_res_initialization.py index fd6a97e3cc8..926aa5f975a 100644 --- a/tests/everest/test_res_initialization.py +++ b/tests/everest/test_res_initialization.py @@ -27,16 +27,22 @@ "config, expected", [ [ + { + "name": "local", + "max_running": 0, + "submit_sleep": 0.0, + "project_code": "", + "activate_script": "activate_script", + }, { "name": "torque", - "queue": "permanent_8", "qsub_cmd": "qsub", "qstat_cmd": "qstat", "qdel_cmd": "qdel", - "keep_qsub_output": 1, - "submit_sleep": 0.5, - "project_code": "snake_oil_pc", - "num_cpus_per_node": 3, + "queue": "queue", + "cluster_label": "cluster_label", + "job_prefix": "job_prefix", + "keep_qsub_output": False, }, { "project_code": "snake_oil_pc", @@ -50,9 +56,16 @@ [ { "name": "slurm", - "partition": "default-queue", - "exclude_host": "host1,host2,host3,host4", - "include_host": "host5,host6,host7,host8", + "sbatch": "sbatch", + "scancel": "scancel", + "scontrol": "scontrol", + "sacct": "sacct", + "squeue": "squeue", + "exclude_host": "exclude_host", + "include_host": "include_host", + "partition": "some_partition", + "squeue_timeout": 2.0, + "max_runtime": 10, }, { "exclude_hosts": "host1,host2,host3,host4", @@ -69,8 +82,13 @@ [ { "name": "lsf", - "lsf_queue": "mr", - "lsf_resource": "span = 1 && select[x86 and GNU/Linux]", + "bhist_cmd": "bhist", + "bjobs_cmd": "bjobs", + "bkill_cmd": "bkill", + "bsub_cmd": "bsub", + "exclude_host": "", + "lsf_queue": "lsf_queue", + "lsf_resource": "", }, { "queue_name": "mr", @@ -80,6 +98,9 @@ ], ) def test_everest_to_ert_queue_config(config, expected): + """Note that these objects are used directly in the Everest + config, and if you have to make changes to this test, it is likely + that it is a breaking change to Everest""" general_queue_options = {"max_running": 10} general_options = {"resubmit_limit": 7}