-
Notifications
You must be signed in to change notification settings - Fork 110
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 test for the propagation of queue_options from ertconfig to cluster #10147
base: main
Are you sure you want to change the base?
Conversation
6772ae3
to
36041df
Compare
CodSpeed Performance ReportMerging #10147 will not alter performanceComparing Summary
|
9e9fb21
to
3c87d49
Compare
792e6b2
to
71393a7
Compare
71393a7
to
a04bc0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the new tests are good :)
@@ -83,18 +83,16 @@ def main() -> None: | |||
|
|||
jobs_output: list[Job] = [] | |||
for job in args.jobs: | |||
job_name: str = read(jobs_path / f"{job}.name") or "_" | |||
job_name: str = read(jobs_path / job / "name") or "_" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes related to "Add tests for the propagation" or does these changes serve some other purpose (was looking for a longer description in the commit message but could not find it).
(two years down the road we will be looking at the git blame for this line and dont get why this was changed based on reading the log message)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just refactoring. In the cases we run multiple realizations with the mocked binaries, I think it makes sense that each job has its own directory instead of prefixing the files with the job_id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the commit message to include this^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If refactoring (and not needed for being able to add tests), it would make sense to have it in a separate commit.
a04bc0b
to
162e24e
Compare
@pytest.mark.usefixtures("copy_poly_case") | ||
def test_queue_options_are_propagated_from_config_to_bsub(monkeypatch): | ||
""" | ||
This end to end test is here to verify that queue_options are correctly propagated all the way from ert config to the cluster. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this could be line formatted, I speculate it extends 88 characters)
job_dir = next( | ||
mock_jobs_dir.iterdir() | ||
) # There is only one realization in this test | ||
complete_command_invocation = (job_dir / "complete_command_invocation").read_text( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as the capturing_bsub
fixture? If it is, maybe consider using that, or is this way better?
) | ||
) | ||
run_cli(ENSEMBLE_EXPERIMENT_MODE, "--disable-monitoring", "poly.ert") | ||
mock_jobs_dir = Path(f"{os.environ.get('PYTEST_TMP_PATH')}/mock_jobs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it smells a little bit to use this environment variable. Will capturing_bsub solve it or can't you find it from cwd
?
job_dir = next( | ||
mock_jobs_dir.iterdir() | ||
) # There is only one realization in this test | ||
complete_command_invocation = (job_dir / "complete_command_invocation").read_text( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check capturing_qsub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capturing_qsub
and capturing_bsub
does not actually run what is submitted, so it wouldn't be a end-to-end test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But scheduler/bin/bsub.py
is just a mock, so this is not an end-to-end test in any case.
If the real bsub
command from LSF gets a breaking change requiring a change in our code, this code will not catch it, so I am unsure if it adds value to this test to use scheduler/bin/bsub.py
over capturing_bsub
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I am only interested in the part from ErtConfig to bsub/qsub/sbatch, so I can probably rewrite the test to be an integration test for ertconfig to driver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some unit tests for this which I could implement for all queue_options like this
@pytest.mark.usefixtures("capturing_bsub")
async def test_submit_with_project_code():
queue_config_dict = {
"QUEUE_SYSTEM": "LSF",
"FORWARD_MODEL": [("FLOW",), ("ECLIPSE",), ("RMS",)],
}
queue_config = QueueConfig.from_dict(queue_config_dict)
driver: LsfDriver = create_driver(queue_config.queue_options)
await driver.submit(0, "sleep")
assert f"-P {queue_config.queue_options.project_code}" in Path(
"captured_bsub_args"
).read_text(encoding="utf-8")
But this part might not be accurate to how we do it in ensemble.py
, and any breaking changes there would not be picked up by the tests.
queue_config = QueueConfig.from_dict(queue_config_dict)
driver: LsfDriver = create_driver(queue_config.queue_options)
assert parsed_options.get("-q") == expected_queue | ||
assert parsed_options.get("-A") == expected_project_code | ||
|
||
# -l was not parsed correctly by getopt, so we read it manually instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need to parse the command line or just rely on certain strings being present in the command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. Very good!
This commit refactors the mocked binaries to have each job use its own sub-directory instead of prefixing the files with job_id.
This commit adds tests that verify that the queue_options are all propagated correctly to the slurm, openpbs, and lsf queue system, using our mocked binaries.
162e24e
to
a4f8e8c
Compare
@@ -223,7 +239,7 @@ async def test_submit_sets_stderr(): | |||
|
|||
|
|||
@pytest.mark.usefixtures("capturing_bsub") | |||
async def test_submit_with_realization_memory_with_bsub_capture(): | |||
async def test_submit_with_realization_memory_with_bsub_capture(): # JONAK - CAN THIS BE REMOVED? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a unit test, but we are testing the same thing in an integration test. Should we keep both as the integration_tests are not run with just rapid-tests
?
e0d02ea
to
cd141a3
Compare
cd141a3
to
9a8ec0e
Compare
General note: it looks to be very complicated. I thought something similar to this test? ert/tests/ert/unit_tests/test_tracking.py Line 147 in 7642464
Which essentially create dedicated models and check that the scheduler got the parameters correctly. |
Issue
Resolves #10141
Approach
Short description of the approach
(Screenshot of new behavior in GUI if applicable)
git rebase -i main --exec 'just rapid-tests'
)When applicable