SingularityApp.hpc-sge-submit
%apphelp hpc-sge-submit
This will print (to the console) an sge submission script.
Note that you can measure time using the appinstall example,
or remove these lines and provide and export the variables
to the app's environment.

    singularity run --app hpc-sge-submit <container>

    # add your email
    singularity run --app hpc-sge-submit <container> vsochat@stanford.edu

    # save to file:
    singularity run --app hpc-sge-submit <container> >> <job-file>.job
    
    # add other arguments
    singularity run --app hpc-sge-submit <container> -q normal

    # Run
    qsub <job-file>.job


%appenv hpc-sge-submit
    DEBIAN_FRONTEND=noninteractive
    export DEBIAN_FRONTEND


%appinstall hpc-sge-submit
    apt-get update && apt-get install -y time
    TIME="TIME_HMS=%E\nMEMORY_KB=%M"
    export TIME

    ### 
    # This command assumes your container has a primary runscript.
    # You can change the path to be another if you like, or simply
    # don't estimate, just export the TIME_HMS and MEMORY_KB in
    # a new %appenv hpc-slurm-submit section
    ###
  
    SCIF_APPNAME= /usr/bin/time -o times.txt /.singularity.d/actions/run

    IFS=''
    while read line
    do
    echo $line >> $SCIF_ENVIRONMENT
    done < times.txt
    echo "export TIME_HMS MEMORY_KB" >> $SCIF_ENVIRONMENT


%apprun hpc-sge-submit
MEMORY_MB=$(echo "$(( ${MEMORY_KB%% *} / 1024))")
echo "#!/bin/bash"
echo "# run_job.sh"
echo "module load singularity"
echo "singularity run $CONTAINER"
echo "# submission command"
QUEUE="-q normal"
if [ $# -ne 0 ]
  then
    QUEUE=$1
fi
echo "# qsub $QUEUE -w e -N pokemon.job -l h_vmem=${MEMORY_MB}G -l h_rt=$TIME_HMS -o pokemon.out -e pokemon.err run_job.sh"

Date: Sep 18, 2017

Author: Vanessa Sochat

Tags: sge scif hpc ubuntu debian singularity

About

Singularity Apps are modular SCI-F apps that can be added as helpers or wrappers for Singularity containers