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

Add queue option validation to queue config #6413

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

xjules
Copy link
Contributor

@xjules xjules commented Oct 24, 2023

Issue
Resolves #6391

Approach
Add validation of option types to each driver.

  • Remove test_that_queue_config_dict_negative_value_invalid test

Pre review checklist

  • Read through the code changes carefully after finishing work
  • Make sure tests pass locally (after every commit!)
  • Prepare changes in small commits for more convenient review (optional)
  • PR title captures the intent of the changes, and is fitting for release notes.
  • Updated documentation
  • Ensured that unit tests are added for all new behavior (See
    Ground Rules),
    and changes to existing code have good test coverage.

Pre merge checklist

  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.

@xjules xjules added the release-notes:misc Automatically categorise as miscellaneous change in release notes label Oct 24, 2023
@xjules xjules self-assigned this Oct 24, 2023
@xjules xjules marked this pull request as ready for review October 25, 2023 11:02
@xjules xjules force-pushed the check_queue_option_types branch 4 times, most recently from 6a336e9 to 865f233 Compare October 26, 2023 13:25
@berland
Copy link
Contributor

berland commented Oct 27, 2023

If you expose the string_options++ in queue_config.py to tests/unit_tests/config/config_dict_generator.py I think you can make the tests quite smart.

src/ert/config/queue_config.py Show resolved Hide resolved
src/ert/config/queue_config.py Show resolved Hide resolved
src/ert/config/queue_config.py Outdated Show resolved Hide resolved
@xjules xjules force-pushed the check_queue_option_types branch 2 times, most recently from 97a7662 to 1ff6e86 Compare October 31, 2023 09:38
@@ -707,8 +707,8 @@ def test_default_ens_path(tmpdir):
"max_running_value, expected_error",
[
(100, None), # positive integer
(-1, "QUEUE_OPTION MAX_RUNNING is negative"), # negative integer
("not_an_integer", "QUEUE_OPTION MAX_RUNNING is not an integer"), # non-integer
(-1, "is not a valid positive integer"), # negative integer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not assert that the string MAX_RUNNING is part of the error? (via regexp if needed)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, tested further below. Do we need this test here then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, maybe we can skip it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code below lacks testing of "-1". The happy path ("100") is probably tested within the hypothesis setup I suppose.

@xjules xjules force-pushed the check_queue_option_types branch 2 times, most recently from c7c9ec0 to 658b66e Compare November 1, 2023 13:21
@berland
Copy link
Contributor

berland commented Nov 1, 2023

Noting that this PR will allow f.ex. QUEUE_OPTION LOCAL MAX_RUNNING fooo if the queue system is set to Torque. Ert-main will not allow fooo here.

@xjules
Copy link
Contributor Author

xjules commented Nov 2, 2023

Noting that this PR will allow f.ex. QUEUE_OPTION LOCAL MAX_RUNNING fooo if the queue system is set to Torque. Ert-main will not allow fooo here.

I see that as up discussion whether we allow some general configs for instance related to other queues (LOCAL) to be set when using TORQUE for instance.

@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2023

Codecov Report

Merging #6413 (5aa7ee6) into main (15c4ae4) will increase coverage by 0.01%.
The diff coverage is 90.90%.

@@            Coverage Diff             @@
##             main    #6413      +/-   ##
==========================================
+ Coverage   83.47%   83.48%   +0.01%     
==========================================
  Files         341      341              
  Lines       20709    20717       +8     
  Branches      938      938              
==========================================
+ Hits        17287    17296       +9     
+ Misses       3131     3130       -1     
  Partials      291      291              
Files Coverage Δ
src/ert/config/__init__.py 100.00% <100.00%> (ø)
src/ert/job_queue/driver.py 97.72% <66.66%> (-2.28%) ⬇️
src/ert/config/queue_config.py 97.43% <93.10%> (-2.57%) ⬇️

... and 1 file with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@berland
Copy link
Contributor

berland commented Nov 2, 2023

I see that as up discussion whether we allow some general configs for instance related to other queues (LOCAL) to be set when using TORQUE for instance.

Should be possible to issue ConfigWarning for errors in not-selected queues.

f"Setting '{option_name}'for {queue_system.name} but "
f"{selected_queue_system.name} is selected. ",
f"Setting '{option_name}' for {queue_system.name} but "
f"{selected_queue_system.name} is selected.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this give warnings if I have valid Torque queue options but Local queue is selected? I don't think I want that, I only want warnings if I have invalid Torque queue options and local is selected.

Copy link
Contributor Author

@xjules xjules Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be validating only when the queue is chosen otherwise just give a warning that you are setting something that is not in used anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, I think it must to be possible to have ert config files that can be used both on LSF and Torque without warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we raise warnings if different queue is set wrongly.

@xjules xjules force-pushed the check_queue_option_types branch 2 times, most recently from 6f4f3de to 39a2783 Compare November 6, 2023 13:49
@@ -77,13 +52,16 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig:
job_script = job_script or "job_dispatch.py"
max_submit: int = config_dict.get("MAX_SUBMIT", 2)
queue_options: Dict[QueueSystem, List[Tuple[str, str]]] = defaultdict(list)
used_queue_systems: Set[QueueSystem] = set()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe configured_queue_systems is more descriptive. I had to read the source in order to understand what used meant in this context.

):
_validate_torque_options(queue_options[QueueSystem.TORQUE])

for queue_system_val in used_queue_systems:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we instead of used_queue_systems do something like queue_options.keys()?

def _validate_queue_driver_settings(
queue_system_options: List[Tuple[str, str]], queue_type: str, throw_error: bool
) -> None:
for option_strings in queue_system_options:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do unpacking of the tuple on the for line, for option_name, option_value in queue_system_options: and then remove the two following lines.

def _validate_torque_options(torque_options: List[Tuple[str, str]]) -> None:
for option_strings in torque_options:
queue_memory_options: Mapping[str, List[str]] = {
"LSF": [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it more consistent to use QueueSystem.LSF instead of the string LSF?

Copy link
Contributor Author

@xjules xjules Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that before, but I changed it due to these *_options are now exposed in tests and didn't want to import all the Cwrap classes there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok!

This still supports unsetting the options when providing an empty string.
Additionally, it raises ValueError when we are not able to set the option
when starting simulation.

If different queue system is ajusted, than currently in use, we validate and issue
only warning instead.

We expose queue_bool_options, queue_memory_options, queue_positive_int_options,
queue_positive_number_options, queue_string_options and
queue_memory_options from ert.config.

NB: when DEBUG_OUTPUT is deprecated it needs to be removed from queue_options.
Copy link
Contributor

@berland berland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets go!

@xjules xjules enabled auto-merge (rebase) November 7, 2023 11:42
@xjules xjules merged commit 9bea497 into equinor:main Nov 7, 2023
43 of 44 checks passed
@xjules xjules deleted the check_queue_option_types branch November 9, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes:misc Automatically categorise as miscellaneous change in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed conversion of queue driver option values are silently ignored
4 participants