From 705f539e2bcef1bf6f4d8d4f992e97360d78fe14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Tue, 26 Nov 2024 13:18:03 +0100 Subject: [PATCH] Make joint option for queue_name --- src/ert/config/queue_config.py | 23 ++++++++++++++----- .../unit_tests/config/test_queue_config.py | 6 ++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/ert/config/queue_config.py b/src/ert/config/queue_config.py index 61a76f68acc..4ba3d2937b2 100644 --- a/src/ert/config/queue_config.py +++ b/src/ert/config/queue_config.py @@ -4,6 +4,7 @@ import re import shutil from abc import abstractmethod +from copy import copy from dataclasses import asdict, field, fields from typing import Any, Dict, List, Literal, Mapping, Optional, Union, no_type_check @@ -32,6 +33,7 @@ class QueueOptions: max_running: pydantic.NonNegativeInt = 0 submit_sleep: pydantic.NonNegativeFloat = 0.0 project_code: Optional[str] = None + queue_name: Optional[NonEmptyString] = None @staticmethod def create_queue_options( @@ -96,7 +98,6 @@ class LsfQueueOptions(QueueOptions): bkill_cmd: Optional[NonEmptyString] = None bsub_cmd: Optional[NonEmptyString] = None exclude_host: Optional[str] = None - lsf_queue: Optional[NonEmptyString] = None lsf_resource: Optional[str] = None @property @@ -104,7 +105,6 @@ def driver_options(self) -> Dict[str, Any]: driver_dict = asdict(self) driver_dict.pop("name") driver_dict["exclude_hosts"] = driver_dict.pop("exclude_host") - driver_dict["queue_name"] = driver_dict.pop("lsf_queue") driver_dict["resource_requirement"] = driver_dict.pop("lsf_resource") driver_dict.pop("submit_sleep") driver_dict.pop("max_running") @@ -117,7 +117,6 @@ class TorqueQueueOptions(QueueOptions): qsub_cmd: Optional[NonEmptyString] = None qstat_cmd: Optional[NonEmptyString] = None qdel_cmd: Optional[NonEmptyString] = None - queue: Optional[NonEmptyString] = None memory_per_job: Optional[NonEmptyString] = None num_cpus_per_node: pydantic.PositiveInt = 1 num_nodes: pydantic.PositiveInt = 1 @@ -132,7 +131,6 @@ class TorqueQueueOptions(QueueOptions): def driver_options(self) -> Dict[str, Any]: driver_dict = asdict(self) driver_dict.pop("name") - driver_dict["queue_name"] = driver_dict.pop("queue") driver_dict.pop("max_running") driver_dict.pop("submit_sleep") driver_dict.pop("qstat_options") @@ -158,7 +156,6 @@ class SlurmQueueOptions(QueueOptions): include_host: str = "" memory: Optional[NonEmptyString] = None memory_per_cpu: Optional[NonEmptyString] = None - partition: Optional[NonEmptyString] = None # aka queue_name squeue_timeout: pydantic.PositiveFloat = 2 max_runtime: Optional[pydantic.NonNegativeFloat] = None @@ -172,7 +169,6 @@ def driver_options(self) -> Dict[str, Any]: driver_dict["squeue_cmd"] = driver_dict.pop("squeue") driver_dict["exclude_hosts"] = driver_dict.pop("exclude_host") driver_dict["include_hosts"] = driver_dict.pop("include_host") - driver_dict["queue_name"] = driver_dict.pop("partition") driver_dict.pop("max_running") driver_dict.pop("submit_sleep") return driver_dict @@ -289,6 +285,21 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig: stop_long_running = config_dict.get(ConfigKeys.STOP_LONG_RUNNING, False) _raw_queue_options = config_dict.get("QUEUE_OPTION", []) + for i, (q_system, *options) in enumerate(copy(_raw_queue_options)): + if ( + (q_system == QueueSystem.LSF and options[0] == "LSF_QUEUE") # noqa: PLR0916 + or (q_system == QueueSystem.SLURM and options[0] == "PARTITION") + or (q_system == QueueSystem.TORQUE and options[0] == "QUEUE") + ): + ConfigWarning.deprecation_warn( + f"Deprecated keyword: {options[0]} for QUEUE_OPTION {q_system}, use: " + f"QUEUE_OPTION GENERIC QUEUE_NAME {options[1] if len(options) >= 2 else ''}", + _raw_queue_options[i], + ) + _raw_queue_options[i] = [ + QueueSystemWithGeneric.GENERIC, + "QUEUE_NAME", + ] + options[1:] _grouped_queue_options = _group_queue_options_by_queue_system( _raw_queue_options ) diff --git a/tests/ert/unit_tests/config/test_queue_config.py b/tests/ert/unit_tests/config/test_queue_config.py index 73e0ad7d680..f1cde452921 100644 --- a/tests/ert/unit_tests/config/test_queue_config.py +++ b/tests/ert/unit_tests/config/test_queue_config.py @@ -216,7 +216,7 @@ def test_that_invalid_memory_pr_job_raises_validation_error( @pytest.mark.parametrize( "queue_system, queue_system_option", - [("LSF", "LSF_QUEUE"), ("SLURM", "SQUEUE"), ("TORQUE", "QUEUE")], + [("LSF", "LSF_QUEUE"), ("SLURM", "PARTITION"), ("TORQUE", "QUEUE")], ) def test_that_overwriting_QUEUE_OPTIONS_warns( queue_system, queue_system_option, caplog @@ -233,7 +233,7 @@ def test_that_overwriting_QUEUE_OPTIONS_warns( f"QUEUE_OPTION {queue_system} MAX_RUNNING 10\n", ) assert ( - f"Overwriting QUEUE_OPTION {queue_system} {queue_system_option}: \n Old value:" + "Overwriting QUEUE_OPTION GENERIC QUEUE_NAME: \n Old value:" " test_0 \n New value: test_1" ) in caplog.text and ( f"Overwriting QUEUE_OPTION {queue_system} MAX_RUNNING: \n Old value:" @@ -256,7 +256,7 @@ def test_initializing_empty_config_queue_options_resets_to_default_value( ) if queue_system == "LSF": - assert config_object.queue_config.queue_options.lsf_queue is None + assert config_object.queue_config.queue_options.queue_name is None if queue_system == "SLURM": assert config_object.queue_config.queue_options.squeue == "squeue" assert config_object.queue_config.queue_options.max_running == 0