Running Simulations on a Cluster¶
The gwmock batch command allows you to build and submit gwmock simulations as
batch jobs on a cluster running either Slurm or HTCondor.
Overview¶
The gwmock batch command has two mutually exclusive modes:
-
Create a batch-ready configuration file from one of the provided examples. This mode is triggered by the
--getoption. -
Generate a scheduler submit file (and optionally submit the job) from an existing configuration file that already contains a
batchsection. The scheduler —slurmorhtcondor— is read frombatch.scheduler.
1. Create a Batch-ready Configuration File¶
Use this mode when starting from an example configuration file in the
examples/
directory and you want to prepare a configuration file that includes all
necessary information for batch submission.
gwmock batch --get <example_label> [options]
This command requires the label of the example configuration file to copy, which
can be obtained using the gwmock config --list command. It copies
examples/<example_label>/config.yaml and adds a complete batch section (see
the Examples page).
Default resources are always added. The keys are scheduler-native — they are emitted verbatim into the submit file — so the defaults differ per scheduler:
nodes: 1
ntasks-per-node: 1
cpus-per-task: 1
mem: 16GB
request_cpus: 1
request_memory: 16GB
request_disk: 4GB
Note
gwmock currently does not support multi-threaded execution. To modify the memory request, edit the configuration file manually.
Commonly used options (only allowed with --get)¶
-
--scheduler <scheduler>Name of the scheduler:slurmorhtcondor. Default:slurm. -
--job-name <name>Job name used in the generated submit file and output file names (stored asbatch.job-name). Default:gwmock_job. -
--account <account>Account/project to charge (stored inbatch.submit). -
--cluster <partition>Cluster or partition to run on (stored inbatch.submit). -
--time <time>Wall time limit inhh:mm:ssformat (stored inbatch.submit). -
--extra-line '<command>'Add a custom shell line to run before the simulation command (e.g. environment setup, module loads, conda activate). Can be repeated multiple times. -
--output <path>Destination for the new configuration file. Default:config.yamlin the current directory. -
--overwriteOverwrite the output configuration file if it already exists.
Scheduler-native keys in batch.submit
Entries under batch.submit are written verbatim into the submit file:
as #SBATCH --<key>=<value> directives for Slurm, and as <key> = <value>
submit commands for HTCondor. The --account, --cluster, and --time
convenience options map to Slurm's sbatch options; for HTCondor, edit
batch.submit in the configuration file and use native submit commands
(e.g. accounting_group) instead.
Example¶
The following command:
gwmock batch --get default_config \
--job-name gwmock_test \
--account my_account \
--cluster cluster_name \
--time 02:00:00 \
--extra-line 'export PATH="/my_account/miniconda3/bin:$PATH"' \
--extra-line 'eval "$(conda shell.bash hook)"' \
--extra-line 'conda activate /my_account/miniconda3/envs/my_env'
add the following batch section to the configuration file:
batch:
scheduler: slurm # Default
job-name: gwmock_test
resources:
nodes: 1 # Default
ntasks-per-node: 1 # Default
cpus-per-task: 1 # Default
mem: 16GB # Default
submit:
account: my_account
cluster: cluster_name
time: 02:00:00
extra_lines:
- export PATH="/my_account/miniconda3/bin:$PATH"
- eval "$(conda shell.bash hook)"
- conda activate /my_account/miniconda3/envs/my_env
An equivalent HTCondor batch section looks like:
batch:
scheduler: htcondor
job-name: gwmock_test
resources:
request_cpus: 1 # Default
request_memory: 16GB # Default
request_disk: 4GB # Default
submit:
accounting_group: my_account
extra_lines:
- export PATH="/my_account/miniconda3/bin:$PATH"
- eval "$(conda shell.bash hook)"
- conda activate /my_account/miniconda3/envs/my_env
2. Generate and Submit a Job¶
Use this mode when you already have a configuration file that contains a valid
batch section.
gwmock batch <config.yaml> [--submit]
This command requires the path to a configuration file that contains a batch
section with at least scheduler and job-name (default resources are
assumed). When executed, the following actions are performed:
-
Directories are created under
<working-directory>/<scheduler>/(i.e.slurm/orhtcondor/):output/– stdout fileserror/– stderr filessubmit/– the generated submit file(s)log/– HTCondor job event logs (HTCondor only)
-
The scheduler-specific submit file is written to
submit/:A single
sbatchscript<job-name>.submitcontaining:- All
#SBATCHdirectives frombatch.resources - Any additional
#SBATCHdirectives frombatch.submit(account, cluster, time, etc.) - All custom lines from
batch.extra_lines(if present) - The command
gwmock simulate <absolute_path_to_config.yaml>
Two files:
<job-name>.sub— the submit description file (universe = vanilla), containing theoutput/error/logpaths, all entries frombatch.resourcesandbatch.submitas submit commands, and aqueuestatement.<job-name>.sh— an executable wrapper script that the job runs on the execute node. HTCondor submit files cannot carry shell setup, so all custom lines frombatch.extra_linesand the commandgwmock simulate <absolute_path_to_config.yaml>live here.
- All
-
If
--submitis used, the job is submitted with the scheduler's native command:sbatchfor Slurm,condor_submitfor HTCondor.
Optional¶
-
--submitImmediately submit the generated job usingsbatchorcondor_submit. Without this flag, only the submit file(s) are created. -
--overwriteOverwrite an existing submit file (and, for HTCondor, wrapper script) if it already exists.
Example¶
# Just generate the submit file(s) in `<working-directory>/<scheduler>/submit`
gwmock batch config.yaml
# Generate and submit immediately
gwmock batch config.yaml --submit