Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
(testing)
Browse files Browse the repository at this point in the history
Add TORQUE option to Everest
  • Loading branch information
Yngve S. Kristiansen committed Sep 4, 2024
1 parent 29ace2b commit 695737a
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/source/config_generated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ Simulation settings


**queue_system (optional)**
Type: *Optional[Literal['lsf', 'local', 'slurm']]*
Type: *Optional[Literal['lsf', 'local', 'slurm', 'torque']]*

Defines which queue system the everest server runs on.

Expand Down
13 changes: 12 additions & 1 deletion src/everest/config/simulator_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SimulatorConfig(BaseModel, HasErtQueueOptions, extra="forbid"): # type: i
Examples to set memory requirement is:
* rusage[mem=1000]""",
)
queue_system: Optional[Literal["lsf", "local", "slurm"]] = Field(
queue_system: Optional[Literal["lsf", "local", "slurm", "torque"]] = Field(
default="local",
description="Defines which queue system the everest server runs on.",
)
Expand Down Expand Up @@ -118,3 +118,14 @@ class SimulatorConfig(BaseModel, HasErtQueueOptions, extra="forbid"): # type: i
the most common use of a standard optimization with a continuous
optimizer.""",
)
qsub_cmd: Optional[str] = Field(default="qsub")
qstat_cmd: Optional[str] = Field(default="qstat")
qdel_cmd: Optional[str] = Field(default="qdel")
qstat_options: Optional[str] = Field(default="-x")
cluster_label: Optional[str] = Field(default=None)
num_nodes: Optional[int] = Field(default=1)
memory_per_job: Optional[str] = Field(default=None)
keep_qsub_output: Optional[int] = Field(default=0)
submit_sleep: Optional[float] = Field(default=0.5)
queue_query_timeout: Optional[int] = Field(default=126)
project_code: Optional[str] = Field(default=None)
12 changes: 12 additions & 0 deletions src/everest/config_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ class ConfigKeys:
TEMPLATE = "template"
TIME_CORR = "time_correlation"
TIMES_LIST = "times_list"
TORQUE = "torque"
TORQUE_QSUB_CMD = "qsub_cmd"
TORQUE_QSTAT_CMD = "qstat_cmd"
TORQUE_QDEL_CMD = "qdel_cmd"
TORQUE_QUEUE_NAME = "name"
TORQUE_CLUSTER_LABEL = "cluster_label"
TORQUE_NUM_NODES = "num_nodes"
TORQUE_NUM_CPUS_PER_NODE = "num_cpus_per_node"
TORQUE_MEMORY_PER_JOB = "memory_per_job"
TORQUE_KEEP_QSUB_OUTPUT = "keep_qsub_output"
TORQUE_SUBMIT_SLEEP = "submit_sleep"
TORQUE_PROJECT_CODE = "project_code"
TYPE = "type"
UPPER_BOUND = "upper_bound"
USER_DEFINED_TYPE = "user_defined_type"
Expand Down
21 changes: 20 additions & 1 deletion src/everest/queue_driver/queue_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@
(ConfigKeys.SLURM_INCLUDE_HOST_OPTION, "INCLUDE_HOST"),
]

_TORQUE_OPTIONS = [
(ConfigKeys.CORES, "MAX_RUNNING"),
(ConfigKeys.TORQUE_QSUB_CMD, "QSUB_CMD"),
(ConfigKeys.TORQUE_QSTAT_CMD, "QSTAT_CMD"),
(ConfigKeys.TORQUE_QDEL_CMD, "QDEL_CMD"),
(ConfigKeys.TORQUE_QUEUE_NAME, "QUEUE"),
(ConfigKeys.TORQUE_CLUSTER_LABEL, "CLUSTER_LABEL"),
(ConfigKeys.TORQUE_NUM_NODES, "NUM_NODES"),
(ConfigKeys.CORES_PER_NODE, "NUM_CPUS_PER_NODE"),
(ConfigKeys.TORQUE_MEMORY_PER_JOB, "MEMORY_PER_JOB"),
(ConfigKeys.TORQUE_KEEP_QSUB_OUTPUT, "KEEP_QSUB_OUTPUT"),
(ConfigKeys.TORQUE_SUBMIT_SLEEP, "SUBMIT_SLEEP"),
(ConfigKeys.TORQUE_PROJECT_CODE, "PROJECT_CODE"),
]


def _extract_ert_queue_options_from_simulator_config(
simulator: Optional[SimulatorConfig], queue_system
Expand All @@ -51,10 +66,14 @@ def _extract_ert_queue_options_from_simulator_config(
return simulator.extract_ert_queue_options(
queue_system=QueueSystem.SLURM, everest_to_ert_key_tuples=_SLURM_OPTIONS
)
elif queue_system == ConfigKeys.TORQUE:
return simulator.extract_ert_queue_options(
queue_system=QueueSystem.TORQUE, everest_to_ert_key_tuples=_TORQUE_OPTIONS
)

raise KeyError(
f"Invalid queue_system: {queue_system}, "
"expected one of: ['lsf', 'local', 'slurm']"
"expected one of: ['lsf', 'local', 'slurm', 'torque']"
)


Expand Down
5 changes: 4 additions & 1 deletion tests/test_config_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@ def test_that_invalid_queue_system_errors():
with pytest.raises(ValueError) as e:
EverestConfig.with_defaults(simulator={"queue_system": "docal"})

assert has_error(e.value, match="Input should be 'lsf', 'local' or 'slurm'")
assert has_error(
e.value, match="Input should be 'lsf', 'local', 'slurm' or 'torque'"
)

EverestConfig.with_defaults(simulator={"queue_system": "local"})
EverestConfig.with_defaults(simulator={"queue_system": "lsf"})
EverestConfig.with_defaults(simulator={"queue_system": "slurm"})
EverestConfig.with_defaults(simulator={"queue_system": "torque"})


@pytest.mark.parametrize(
Expand Down
71 changes: 71 additions & 0 deletions tests/test_data/snake_oil/everest/model/snake_oil_torque.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
definitions:
eclbase: eclipse/ECL

wells:
- {name: W1}
- {name: W2}
- {name: W3}
- {name: W4}

controls:
-
name: group_0
type: well_control
min: 0
max: 1
variables:
-
name: W1
initial_guess: 0
-
name: W2
initial_guess: 0
-
name: W3
initial_guess: 1
-
name: W4
initial_guess: 1

objective_functions:
-
name: snake_oil_nvp

install_jobs:
-
name: snake_oil_diff
source: ../../jobs/SNAKE_OIL_DIFF
-
name: snake_oil_simulator
source: ../../jobs/SNAKE_OIL_SIMULATOR
-
name: snake_oil_npv
source: ../../jobs/SNAKE_OIL_NPV

optimization:
algorithm: optpp_q_newton

simulator:
max_runtime: 3600
queue_system: torque
name: snake_queue
qsub_cmd: "qsub"
qstat_cmd: "qstat"
qdel_cmd: "qdel"
cluster_label: "testing_it"
num_nodes: 1
memory_per_job: "2gb"
keep_qsub_output: 1
submit_sleep: 0.5
project_code: "snake_oil_pc"

environment:
simulation_folder: simulations

model:
realizations: [0]

forward_model:
- snake_oil_simulator
- snake_oil_npv
- snake_oil_diff
47 changes: 47 additions & 0 deletions tests/test_res_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,53 @@ def test_snake_everest_to_ert_slurm():
)


@tmpdir(relpath("test_data"))
def test_snake_everest_to_ert_torque():
snake_torque_config_path = os.path.join(SNAKE_CONFIG_DIR, "snake_oil_torque.yml")

ever_config_dict = EverestConfig.load_file(snake_torque_config_path)
ert_config_dict = everest_to_ert_config(ever_config_dict)

assert ert_config_dict["QUEUE_SYSTEM"] == "TORQUE"

expected_queue_option_tuples = {
("TORQUE", "QSUB_CMD", "qsub"),
("TORQUE", "QSTAT_CMD", "qstat"),
("TORQUE", "QDEL_CMD", "qdel"),
("TORQUE", "QUEUE", "snake_queue"),
("TORQUE", "CLUSTER_LABEL", "testing_it"),
("TORQUE", "NUM_NODES", 1),
("TORQUE", "MEMORY_PER_JOB", "2gb"),
("TORQUE", "KEEP_QSUB_OUTPUT", 1),
("TORQUE", "SUBMIT_SLEEP", 0.5),
("TORQUE", "PROJECT_CODE", "snake_oil_pc"),
}

assert set(ert_config_dict["QUEUE_OPTION"]) == expected_queue_option_tuples

ert_config = ErtConfig.with_plugins().from_dict(
config_dict=everest_to_ert_config(
ever_config_dict, site_config=ErtConfig.read_site_config()
)
)

qc = ert_config.queue_config
qo = qc.queue_options
assert qc.queue_system == "TORQUE"
assert qo.driver_options == {
"project_code": "snake_oil_pc",
"qsub_cmd": "qsub",
"qstat_cmd": "qstat",
"qdel_cmd": "qdel",
"memory_per_job": "2gb",
"num_cpus_per_node": 1,
"num_nodes": 1,
"cluster_label": "testing_it",
"keep_qsub_output": True,
"queue_name": "snake_queue",
}


@patch.dict("os.environ", {"USER": "NO_USERNAME"})
@tmpdir(relpath("test_data"))
def test_tutorial_everest_to_ert():
Expand Down

0 comments on commit 695737a

Please sign in to comment.