Create sbatch Array Job with the same size as a parameter file
This script creates a sbatch array job with the same size as a parameter file. The parameter file is a text file with one line per job. The script reads the parameter file and creates a sbatch array job with the same number of jobs as lines in the parameter file, with the option to specify the maximum number of jobs to run concurrently.
This is similar to oarsub --array-param-file <file> in OAR. But it won't launch the jobs automatically, you need to submit the job array manually.
Usage
First make sure that your script has a logic that takes in the job index from slurm and reads the corresponding line from the parameter file. For example add this to your script:
args=$(sed -n ${SLURM_ARRAY_TASK_ID}p $1)
echo "Running with the following parameters:"
echo $args
IFS=' ' read -r -a array <<< $args
var1=${array[0]}
var2=${array[1]}
var3=${array[2]}
echo "var1: $var1"
echo "var2: $var2"
echo "var3: $var3"
Then run the tool to create the sbatch script from an existing sbatch file and a parameter file:
sbatch_paramfile <sbatch_file> <param_file> --max_run_jobs <max_run_jobs>
This will create a new sbatch file with the same name as the original sbatch file, but with _paramfile appended to the name. This new sbatch file will have the same number of jobs as lines in the parameter file, and it will add the #SBATCH --array=1-<number_of_jobs>%<max_run_jobs> line to the sbatch file.
Then submit the job array:
sbatch <output_sbatch_file> <param_file>
Contact
Metadata
Release files for sbatch-paramfile 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sbatch_paramfile-0.1.1.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sbatch_paramfile-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.3 kB
Release files / sbatch_paramfile-0.1.1.tar.gz
| Download URL | sbatch_paramfile-0.1.1.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe39eafcfe0ab95ae84c510ab664719f58dbd3e741c0a246a74985bf38a94a96
|
|
BLAKE2b-256 checksum How to use checksums |
97a229cdbc3b6a21dd5e219e383545db284893e5ae8f730980545c18269f26dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / sbatch_paramfile-0.1.1-py3-none-any.whl
| Download URL | sbatch_paramfile-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bea7aaf02df2c8e41de8a2185dba4f9f72ef47ddf3e3d4d44c5d565f1d796965
|
|
BLAKE2b-256 checksum How to use checksums |
e51357c26f5ff6311f8f0535b6b18fe1d4ede1831f530055455744cbf14950b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|