Skip to content

Commit

Permalink
Refine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Jan 10, 2025
1 parent 1a0ba33 commit df6a303
Showing 1 changed file with 17 additions and 37 deletions.
54 changes: 17 additions & 37 deletions tests/everest/test_res_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
import everest
from ert.config import ExtParamConfig
from ert.config.parsing import ConfigKeys as ErtConfigKeys
from ert.config.queue_config import (
LocalQueueOptions,
LsfQueueOptions,
SlurmQueueOptions,
TorqueQueueOptions,
)
from everest import ConfigKeys as CK
from everest.config import EverestConfig, EverestValidationError
from everest.simulator.everest_to_ert import (
Expand All @@ -24,7 +30,7 @@


@pytest.mark.parametrize(
"config, expected",
"config, config_class",
[
[
{
Expand All @@ -34,6 +40,9 @@
"project_code": "",
"activate_script": "activate_script",
},
LocalQueueOptions,
],
[
{
"name": "torque",
"qsub_cmd": "qsub",
Expand All @@ -44,14 +53,7 @@
"job_prefix": "job_prefix",
"keep_qsub_output": False,
},
{
"project_code": "snake_oil_pc",
"qsub_cmd": "qsub",
"qstat_cmd": "qstat",
"qdel_cmd": "qdel",
"keep_qsub_output": True,
"queue_name": "permanent_8",
},
TorqueQueueOptions,
],
[
{
Expand All @@ -67,17 +69,7 @@
"squeue_timeout": 2.0,
"max_runtime": 10,
},
{
"exclude_hosts": "host1,host2,host3,host4",
"include_hosts": "host5,host6,host7,host8",
"queue_name": "default-queue",
"sacct_cmd": "sacct",
"sbatch_cmd": "sbatch",
"scancel_cmd": "scancel",
"scontrol_cmd": "scontrol",
"squeue_cmd": "squeue",
"squeue_timeout": 2,
},
SlurmQueueOptions,
],
[
{
Expand All @@ -90,37 +82,25 @@
"lsf_queue": "lsf_queue",
"lsf_resource": "",
},
{
"queue_name": "mr",
"resource_requirement": "span = 1 && select[x86 and GNU/Linux]",
},
LsfQueueOptions,
],
],
)
def test_everest_to_ert_queue_config(config, expected):
def test_everest_to_ert_queue_config(config, config_class):
"""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}

config |= general_queue_options
ever_config = EverestConfig.with_defaults(
**{
"simulator": {"queue_system": config | general_queue_options}
| general_options,
"simulator": {"queue_system": config} | general_options,
"model": {"realizations": [0]},
}
)
ert_config = everest_to_ert_config(ever_config)

qc = ert_config.queue_config
qo = qc.queue_options
assert str(qc.queue_system) == config["name"]
driver_options = qo.driver_options
driver_options.pop("activate_script")
assert {k: v for k, v in driver_options.items() if v is not None} == expected
assert qc.max_submit == general_options["resubmit_limit"] + 1
assert qo.max_running == general_queue_options["max_running"]
assert ert_config.queue_config.queue_options == config_class(**config)


def test_everest_to_ert_controls():
Expand Down

0 comments on commit df6a303

Please sign in to comment.