Skip to content

Commit

Permalink
Remove simulation server option and add deprecation warning is presen…
Browse files Browse the repository at this point in the history
…t in config
  • Loading branch information
DanSava committed Nov 5, 2024
1 parent 8c679c1 commit 58be1fc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/everest/config_generated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ Simulation settings
**server (optional)**
Type: *Optional[str]*

Name of LSF server to use
Name of LSF server to use. This option is deprecated and not longer required


**slurm_timeout (optional)**
Expand Down
18 changes: 16 additions & 2 deletions src/everest/config/simulator_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import warnings
from typing import Literal, Optional

from pydantic import BaseModel, Field, NonNegativeInt, PositiveInt
from pydantic import BaseModel, Field, NonNegativeInt, PositiveInt, field_validator

from .has_ert_queue_options import HasErtQueueOptions

Expand Down Expand Up @@ -96,7 +97,10 @@ class SimulatorConfig(BaseModel, HasErtQueueOptions, extra="forbid"): # type: i
default=None,
description="squeue executable to be used by the slurm queue interface.",
)
server: Optional[str] = Field(default=None, description="Name of LSF server to use")
server: Optional[str] = Field(
default=None,
description="Name of LSF server to use. This option is deprecated and not longer required",
)
slurm_timeout: Optional[int] = Field(
default=None,
description="Timeout for cached status used by the slurm queue interface",
Expand Down Expand Up @@ -155,3 +159,13 @@ class SimulatorConfig(BaseModel, HasErtQueueOptions, extra="forbid"): # type: i
default=None,
description="String identifier used to map hardware resource usage to a project or account. The project or account does not have to exist.",
)

@field_validator("server")
@classmethod
def valiate_server(cls, server): # pylint: disable=E0213
if server is not None and server:
warnings.warn(
"The simulator server property was deprecated and is no longer needed",
DeprecationWarning,
stacklevel=1,
)
1 change: 0 additions & 1 deletion src/everest/config_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class ConfigKeys:
LSF = "lsf"
LSF_OPTIONS = "options" # LSF_RESOURCES
LSF_QUEUE_NAME = "name"
LSF_SERVER = "server"
SLURM = "slurm"
SLURM_QUEUE = "name"
SLURM_SBATCH = "sbatch"
Expand Down
1 change: 0 additions & 1 deletion src/everest/queue_driver/queue_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
_LSF_OPTIONS = [
(ConfigKeys.CORES, "MAX_RUNNING"),
(ConfigKeys.LSF_QUEUE_NAME, "LSF_QUEUE"),
(ConfigKeys.LSF_SERVER, "LSF_SERVER"),
(ConfigKeys.LSF_OPTIONS, "LSF_RESOURCE"),
]

Expand Down
17 changes: 17 additions & 0 deletions tests/everest/test_everest_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pathlib import Path
from typing import List

import pytest

from everest.config import EverestConfig
from everest.config.control_config import ControlConfig
from everest.config.control_variable_config import ControlVariableConfig
Expand Down Expand Up @@ -284,3 +286,18 @@ 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("server", ["something", "", None])
def test_deprecation_warning_for_simulator_server(server):
config_src = {"simulator": {"server": server}}

if not server:
config = EverestConfig.with_defaults(**config_src)
else:
with pytest.deprecated_call(
match="The simulator server property was deprecated"
):
config = EverestConfig.with_defaults(**config_src)

assert config.simulator.server is None
3 changes: 1 addition & 2 deletions tests/everest/test_res_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ def test_queue_configuration(copy_test_data_to_tmp):
expected_options = [
("LSF", "MAX_RUNNING", 3),
("LSF", "LSF_QUEUE", "mr"),
("LSF", "LSF_SERVER", "lx-fastserver01"),
("LSF", "LSF_RESOURCE", "span = 1 && select[x86 and GNU/Linux]"),
]

Expand All @@ -400,7 +399,7 @@ def test_queue_config():
assert config.simulator.resubmit_limit == 17
assert config.simulator.cores == 3
assert config.simulator.queue_system == "lsf"
assert config.simulator.server == "lx-fastserver01"
assert config.simulator.server is None
opts = "span = 1 && select[x86 and GNU/Linux]"
assert opts == config.simulator.options

Expand Down

0 comments on commit 58be1fc

Please sign in to comment.