Validate job options before writing the job script - #1837
Draft
Mohit-Ak wants to merge 1 commit into
Draft
Conversation
run() rendered and wrote <name>.sh (and, with --clean, wiped the previous outputs and kicked off a build) before __validate_job_options() had a chance to refuse the invocation, so `--no-mpi` with several ranks, `nodes <= 0`, or a malformed `--email` aborted the run but left a stale job script behind. Move the validation to the top of run(), right after the case is loaded, so an invalid invocation is rejected before any side effect. Add unit tests that drive run() with each rejected option combination and assert that neither build, case.clean(), the job-script generator nor the input-file generator was invoked, plus a control that a valid invocation still reaches generation. Fixes MFlowCode#1511 (part b).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
run()currently does its option validation after it has already rendered and written the job script:__validate_job_options()raises for--no-mpiwith more than one rank,nodes <= 0,tasks_per_node <= 0, or a malformed--email. Because it runs late, any of those aborts the run but leaves a freshly written<name>.shin the case directory — and, since--cleanandbuild()also run before it, a rejected invocation has by then already wiped the previous run's outputs and possibly triggered a build.This moves
__validate_job_options()to the top ofrun(), right after the targets are resolved and before the case file is loaded (loading executescase.py, so it's a side effect too). Validation only readsARG(...), so the reorder has no other effect; valid invocations behave exactly as before.Testing. Added
toolchain/mfc/run/test_run.py, which drivesrun()under a sandboxedstate.gARGwith each rejected option combination and asserts thatbuild,case.clean(), the job-script generator and the input-file generator were all not called, plus a control case that a valid invocation still reaches generation. On pristinemasterthe four rejection tests fail (AssertionError: job script was written before option validation); with this change all five pass.This is part (b) of #1511 only, per the issue's own suggestion to split it from the (a)/(c)/(d) tidy-ups.
Fixes #1511