Demonstrate running Python code within a conda env, as a Slurm job array.
- Multiple instances of the same code is run with different parameters.
- Each run only differs in that it has a different value for "task ID".
- The task ID can be used to select a predefined paramter set, create random numbers, or in other ways.
conda env create -f environment.yaml
source activate ensemble
python example.py --task_id 1
sbatch job_script.sh
- Job script uses special comments to set up Slurm job array.
- When submitted to Slurm, multiple sub-jobs are created. Each has a different value for $SLURM_ARRAY_TASK_ID.
- When each sub-job runs the job script loads our conda environment by name.
- Job script then runs our Python script, using task ID value as command line parameter.
- Python code accepts the task ID value as a command line parameter and uses it to figure out which of its own interal parameter values to use.
- The job scripts sets the Slurm "account" (queue) to "standby". Change this as needed.