Part of #4950. Slice 2 of 5. Estimated 4 weeks. Depends on #4996.
Goal
Move batch logic from scattered locations (XML/env_batch.py,
case/case_submit.py, utils.py) into a coherent CIME/core/batch/ package.
Existing entrypoints become thin wrappers.
Why
EnvBatch (XML/env_batch.py, 1590 lines, 43 methods) is the second-largest
class in CIME. It handles batch config parsing, job submission, queue
management, and directive generation all in one class. Submission logic is
also smeared into case_submit.py and utils.py.
Tasks
Decompose EnvBatch
Scheduler protocol
Move from utils.py → core/batch/
Move from utils.py → core/shell.py
Consolidation
Imports & re-exports
Definition of done
Related
Part of #4950. Slice 2 of 5. Estimated 4 weeks. Depends on #4996.
Goal
Move batch logic from scattered locations (
XML/env_batch.py,case/case_submit.py,utils.py) into a coherentCIME/core/batch/package.Existing entrypoints become thin wrappers.
Why
EnvBatch(XML/env_batch.py, 1590 lines, 43 methods) is the second-largestclass in CIME. It handles batch config parsing, job submission, queue
management, and directive generation all in one class. Submission logic is
also smeared into
case_submit.pyandutils.py.Tasks
Decompose
EnvBatchCIME/core/batch/config.py— batch config / queue parsing.CIME/core/batch/submit.py— job submission logic (consumes fromEnvBatchandcase_submit.py).CIME/core/batch/directives.py— directive generation.EnvBatchbecomes a thinner wrapper delegating to the above.Scheduler protocol
Schedulerprotocol inCIME/core/batch/scheduler.py.PBS, Slurm, LSF are genuine polymorphic backends — DI is warranted here.
PBSScheduler,SlurmScheduler,LSFScheduler.Move from
utils.py→core/batch/batch_jobid,get_batch_script_for_job,get_project,get_charge_account,add_mail_type_args,resolve_mail_type_args,transform_vars.Move from
utils.py→core/shell.pyrun_cmd,run_cmd_no_fail(general utility, pulled here because batchis the first heavy consumer).
Consolidation
transform_vars(utils.py:2118) takescaseand callscase.get_value()repeatedly — consolidate as aCasemethod, withcore template logic in
CIME/core/batch/.batch_jobid(utils.py:2360) callscase.get_job_id()— move intothe batch subsystem.
Imports & re-exports
core/batch/.utils.py,case/case_submit.pyfor externalconsumers.
Definition of done
core/batch/, not inXML/,case/,utils.py.EnvBatchis a thin wrapper.Schedulerprotocol with PBS/Slurm/LSF implementations.core/batch/.Related
CIME/core/build/#4999 (build orchestration may depend on batch interface)