Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add warning when overwriting QUEUE_OPTION (#5993)" #6032

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 2 additions & 31 deletions src/ert/config/queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import re
import shutil
import warnings
from collections import Counter, defaultdict
from collections import defaultdict
from dataclasses import dataclass, field
from typing import Any, Dict, List, Tuple, Union, no_type_check

from ert import _clib

from .parsing import ConfigDict, ConfigValidationError, ConfigWarning, ErrorInfo
from .parsing import ConfigDict, ConfigValidationError, ErrorInfo
from .queue_system import QueueSystem

GENERIC_QUEUE_OPTIONS: List[str] = ["MAX_RUNNING"]
Expand Down Expand Up @@ -101,14 +100,6 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig:
):
_validate_torque_options(queue_options[QueueSystem.TORQUE])

if (
selected_queue_system != QueueSystem.LOCAL
and queue_options[selected_queue_system]
):
_check_for_overwritten_queue_system_options(
queue_options[selected_queue_system]
)

return QueueConfig(job_script, max_submit, selected_queue_system, queue_options)

def create_local_copy(self) -> QueueConfig:
Expand All @@ -120,26 +111,6 @@ def create_local_copy(self) -> QueueConfig:
)


def _check_for_overwritten_queue_system_options(
queue_system_options: List[Tuple[str, str]]
) -> None:
keywords_counter = Counter(
[
option_string[0]
for option_string in queue_system_options
if option_string[0] != "MAX_RUNNING"
]
)
for keyword, keyword_count in keywords_counter.items():
if keyword_count > 1:
warnings.warn(
ConfigWarning(
f"Overwriting {keyword} keyword, this may lead to an error."
),
stacklevel=1,
)


def _validate_torque_options(torque_options: List[Tuple[str, str]]) -> None:
for option_strings in torque_options:
if isinstance(option_strings, tuple):
Expand Down
35 changes: 1 addition & 34 deletions tests/unit_tests/config/test_queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
import pytest
from hypothesis import given

from ert.config import (
ConfigValidationError,
ConfigWarning,
ErtConfig,
QueueConfig,
QueueSystem,
)
from ert.config import ConfigValidationError, ErtConfig, QueueConfig, QueueSystem
from ert.job_queue import Driver


Expand Down Expand Up @@ -133,30 +127,3 @@ def test_torque_queue_config_invalid_memory_pr_job(memory_with_unit_str):
f.write(f"QUEUE_OPTION TORQUE MEMORY_PER_JOB {memory_with_unit_str}")
with pytest.raises(ConfigValidationError):
ErtConfig.from_file(filename)


@pytest.mark.usefixtures("use_tmpdir")
@pytest.mark.parametrize(
"queue_system, queue_system_option",
[("LSF", "LSF_SERVER"), ("SLURM", "SQUEUE"), ("TORQUE", "QUEUE")],
)
def test_overwriting_QUEUE_OPTIONS_warning(
tmp_path, monkeypatch, queue_system, queue_system_option
):
filename = "config.ert"
with open(filename, "w", encoding="utf-8") as f:
f.write("NUM_REALIZATIONS 1\n")
f.write(f"QUEUE_SYSTEM {queue_system}\n")
f.write(f"QUEUE_OPTION {queue_system} {queue_system_option} test_1\n")
test_site_config = tmp_path / "test_site_config.ert"
test_site_config.write_text(
"JOB_SCRIPT job_dispatch.py\n"
f"QUEUE_SYSTEM {queue_system}\n"
f"QUEUE_OPTION {queue_system} {queue_system_option} test_2\n"
)
monkeypatch.setenv("ERT_SITE_CONFIG", str(test_site_config))
with pytest.warns(
ConfigWarning,
match=rf"Overwriting {queue_system_option} keyword, this may lead to an error.",
):
ErtConfig.from_file(filename)
Loading