Skip to content

Commit

Permalink
Singularity -> Apptainer
Browse files Browse the repository at this point in the history
  • Loading branch information
jgainerdewar committed Jan 17, 2025
1 parent 4c70163 commit ebaaa32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/ci/bin/test_slurm.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ cromwell::build::slurm::setup_slurm_environment() {
sudo mkdir -p /var/spool/slurmd
sudo chown slurm:slurm /var/spool/slurmd

# Set up an AppArmor profile for singularity to allow non-root users to use it.
# Set up an AppArmor profile for Apptainer to allow non-root users to use it.
# This became required in Ubuntu 24.04
sudo tee /etc/apparmor.d/singularity << 'EOF'
sudo tee /etc/apparmor.d/apptainer << 'EOF'
abi <abi/4.0>,
include <tunables/global>
profile singularity /usr/bin/singularity{,-suid} flags=(unconfined) {
profile apptainer /usr/bin/apptainer{,-suid} flags=(unconfined) {
userns,
}
EOF

# Reload to get new profile created above
sudo systemctl reload apparmor

# A mash of configure-until-it-runs. Feel free to PR suggestions/fixes.
Expand Down
11 changes: 4 additions & 7 deletions src/ci/resources/slurm_application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,24 @@ backend {
# https://slurm.schedmd.com/sbatch.html
submit-docker = """
set -euo pipefail
CACHE_DIR=$HOME/.singularity/cache
CACHE_DIR=$HOME/.apptainer/cache
mkdir -p $CACHE_DIR
LOCK_FILE=$CACHE_DIR/singularity_pull_flock
LOCK_FILE=$CACHE_DIR/apptainer_pull_flock
DOCKER_NAME=$(sed -e 's/[^A-Za-z0-9._-]/_/g' <<< ${docker})
IMAGE=$CACHE_DIR/$DOCKER_NAME.sif
(
flock --verbose --exclusive --timeout 900 9 || exit 1
if [ ! -e "$IMAGE" ]; then
singularity build $IMAGE docker://${docker}
apptainer build $IMAGE docker://${docker}
fi
) 9>$LOCK_FILE

echo "I am..."
whoami

sbatch \
-J ${job_name} \
-D ${cwd} \
-o ${cwd}/execution/stdout \
-e ${cwd}/execution/stderr \
--wrap "singularity exec --containall --bind ${cwd}:${docker_cwd} $IMAGE ${job_shell} ${docker_script}"
--wrap "apptainer exec --containall --bind ${cwd}:${docker_cwd} $IMAGE ${job_shell} ${docker_script}"
"""

# https://slurm.schedmd.com/scancel.html
Expand Down

0 comments on commit ebaaa32

Please sign in to comment.