I am using a high-performance research cloud at my university that utilizes the Slurm workload manager (I am very unfamiliar with this type of computing). I have figured out enough to get a batch job running using an array, but I was wondering if there was a way to get the job name to reflect the array task ID.
For reference, we were previously using MOAB and my previous submit file looked like this (and would correctly name the job with the loop index)
for i in {1..50}
do
#submit a job and pass the jobid $i
qsub -v INPUT=$i -N jobname_${i} pbs_script.pbs
done
My attempt within Slurm so far has looked like this
#SBATCH --job-name=test$SLURM_ARRAY_TASK_ID
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --array=1-100
cd $SLURM_SUBMIT_DIR
module load r/4.3.1
Rscript test.R
This code works and I run 100 different jobs of my R script fine but the job names do not reflect the task ID (they all just literally say "test$SLURM_ARRAY_TASK_ID". I'm not finding any sort of solution online (if it's even possible). Basically, when I submit this job and it becomes 100 jobs, I want each of the job names in the queue to accurately reflect their task ID number, i.e., test1, test2, etc...
Thank you in advance!
Unfortunately it is not possible since only one job record is created while submitting the array job.
As per Slurm documentation:
When a job array is submitted to Slurm, only one job record is created. Additional job records will only be created when the state of a task in the job array changes, typically when a task is allocated resources or its state is modified using the scontrol command. By default, the squeue command will report all of the tasks associated with a single job record on one line and use a regular expression to indicate the "array_task_id" values as shown below.
Nevertheless, when a job array is submitted, you can see the individual job step status while using the squeue command. For example,
$ sbatch --array=1-4 -J array ./sleepme 86400
Submitted batch job 21845
$ squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST
21845_1 canopo array david R 0:13 1 dario
21845_2 canopo array david R 0:13 1 dario
21845_3 canopo array david R 0:13 1 dario
21845_4 canopo array david R 0:13 1 dario
If you look into JOBID
, it will showcase the array ID along with Job ID (Format: JOBID_TASKID).
However, if you want to see different job names, then you need to call your job script
inside a loop with job name as argument. For example, consider the psuedocode:
for index in 1 2 3 4 5 .. N
do
sbatch -J test_$index job_script.sh #will set test_1 as first jobname
done