feat(flux): support omit_in_job attribute on submit args to drop args invalid inside a job - #5020
Open
jasonb5 wants to merge 2 commits into
Open
feat(flux): support omit_in_job attribute on submit args to drop args invalid inside a job#5020jasonb5 wants to merge 2 commits into
jasonb5 wants to merge 2 commits into
Conversation
…id inside a job Schedulers like flux give each job an ephemeral nested instance where some submit args (e.g. -p <partition>) are invalid, so args marked omit_in_job="true" are dropped when submission happens from inside an already-running batch job, detected via well-known scheduler environment variables. Closes #5018
Collaborator
Author
|
Needs testing on actual machine still. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an omit_in_job attribute for batch submit arguments so args that are only valid when submitting outside an existing batch job can be automatically dropped when submissions occur from inside a running job (e.g., Flux nested instances where stale partition args like -p <partition> fail). It extends EnvBatch with an in-job detection helper based on scheduler-specific environment variables and adds unit tests for the new behavior.
Changes:
- Add
omit_in_job(xs:boolean) to<arg>and<argument>submit args inconfig_batch.xsd. - Add
EnvBatch.is_in_batch_job()and applyomit_in_jobfiltering while resolving submit args. - Add pytest unit tests covering omit/not-omit behavior based on in-job environment context.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| CIME/XML/env_batch.py | Adds in-job detection and omits submit args marked omit_in_job when running inside a batch job. |
| CIME/tests/test_unit_xml_env_batch.py | Adds unit tests for omit_in_job behavior and unknown scheduler handling. |
| CIME/data/config/xml_schemas/config_batch.xsd | Extends schema to allow omit_in_job attribute on submit argument elements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+31
to
+41
| IN_JOB_ENVIRONMENT_VARIABLES = { | ||
| "flux": "FLUX_JOB_ID", | ||
| "lsf": "LSB_JOBID", | ||
| "pbs": "PBS_JOBID", | ||
| "pbspro": "PBS_JOBID", | ||
| "moab": "PBS_JOBID", | ||
| "slurm": "SLURM_JOB_ID", | ||
| "slurm_single_node": "SLURM_JOB_ID", | ||
| "cobalt": "COBALT_JOBID", | ||
| "cobalt_theta": "COBALT_JOBID", | ||
| } |
Comment on lines
+1395
to
+1405
| def test_is_in_batch_job_unknown_batch_system(monkeypatch): | ||
| # Context | ||
| batch = EnvBatch() | ||
|
|
||
| batch._batchtype = "made_up_scheduler" | ||
|
|
||
| monkeypatch.setenv("SLURM_JOB_ID", "1234") | ||
|
|
||
| # Act/Assert | ||
| assert not batch.is_in_batch_job() | ||
|
|
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.
Summary
omit_in_jobboolean attribute to<arg>and<argument>submit args inconfig_batch.xsd; args markedomit_in_job="true"are dropped when submission happens from inside an already-running batch job.EnvBatch.is_in_batch_job(), detecting in-job context via a small static scheduler→env-var mapping (FLUX_JOB_ID,SLURM_JOB_ID,PBS_JOBID,LSB_JOBID,COBALT_JOBID). Only the current batch system's env var is considered.-p <partition>fails on in-job resubmit. The mechanism is generic/attribute-driven so other args can opt in without code changes.Testing
CIME/tests/test_unit_xml_env_batch.pycovering in-job, not-in-job, other-scheduler env var present (ignored), and unknown batch system cases; full file passes (29 tests).Follow-up
omit_in_job="true"to-pfor Tuolumne's fluxconfig_batch.xml.RESUBMIT>=1.Closes #5018