This function builds a template for a Son of Grid Ending (SGE) job script including array jobs. Check this blog post by John Muschelli to learn more about array jobs: https://hopstat.wordpress.com/2013/11/05/array-and-sequential-cluster-jobs/.

job_single(
  name,
  create_shell = FALSE,
  queue = "shared",
  memory = "10G",
  cores = 1L,
  email = "e",
  logdir = "logs",
  filesize = "100G",
  task_num = NULL,
  tc = 20,
  command = "Rscript -e \"options(width = 120); sessioninfo::session_info()\"",
  create_logdir = TRUE
)

Arguments

name

A character(1) vector with the name of the script. Any spaces will be replaced by underscores.

create_shell

A logical(1) vector specifying whether to create a shell file for the script.

queue

A character(1) vector with the name of the SGE queue. Check how busy a given queue is by running qpic -q queuename.

memory

The amount of memory per core to request in SGE syntax. You can check how much a current job is utilizing using the qmem JHPCE command. For more detail on the memory options, check https://jhpce.jhu.edu/knowledge-base/how-to/#MemSpec.

cores

The number of cores to request. Note that the total memory your job will request is cores multiplied by memory.

email

The email reporting option for the email. For more information check https://jhpce.jhu.edu/knowledge-base/how-to/#Email.

logdir

The directory for the SGE log files relative to the current working directory.

filesize

The maximum file size in SGE format.

task_num

The number of tasks for your job, which will make it into an array job. If NULL this is ignored.

tc

If task_num is specified, this option controls the number of concurrent tasks.

command

An example command to start your script.

create_logdir

A logical(1) vector specifying whether to create the logdir directory. Note that if logdir doesn't exist and you submit your job with qsub, it will immediately fail.

Value

A character vector with the script contents. If create_shell was specified then it also creates the actual script in the current working directory.

Details

For a given SGE job that is currently running you can alter the options using qalter.

Author

Leonardo Collado-Torres

Examples


## A regular job
job_single("jhpce_job", create_logdir = FALSE)
#> #!/bin/bash
#> #$ -cwd
#> #$ -l mem_free=10G,h_vmem=10G,h_fsize=100G
#> #$ -N jhpce_job
#> #$ -o logs/jhpce_job.txt
#> #$ -e logs/jhpce_job.txt
#> #$ -m e
#> 
#> echo "**** Job starts ****"
#> date
#> 
#> echo "**** JHPCE info ****"
#> echo "User: ${USER}"
#> echo "Job id: ${JOB_ID}"
#> echo "Job name: ${JOB_NAME}"
#> echo "Hostname: ${HOSTNAME}"
#> echo "Task id: ${SGE_TASK_ID}"
#> 
#> ## Load the R module (absent since the JHPCE upgrade to CentOS v7)
#> module load conda_R
#> 
#> ## List current modules for reproducibility
#> module list
#> 
#> ## Edit with your job command
#> Rscript -e "options(width = 120); sessioninfo::session_info()"
#> 
#> echo "**** Job ends ****"
#> date
#> 
#> ## This script was made using sgejobs version 0.99.2
#> ## available from http://research.libd.org/sgejobs/
#> 

## A regular job with 10 cores on the 'imaginary' queue
job_single("jhpce_job",
    cores = 10, queue = "imaginary",
    create_logdir = FALSE
)
#> #!/bin/bash
#> #$ -cwd
#> #$ -l imaginary,mem_free=10G,h_vmem=10G,h_fsize=100G
#> #$ -pe local 10
#> #$ -N jhpce_job
#> #$ -o logs/jhpce_job.txt
#> #$ -e logs/jhpce_job.txt
#> #$ -m e
#> 
#> echo "**** Job starts ****"
#> date
#> 
#> echo "**** JHPCE info ****"
#> echo "User: ${USER}"
#> echo "Job id: ${JOB_ID}"
#> echo "Job name: ${JOB_NAME}"
#> echo "Hostname: ${HOSTNAME}"
#> echo "Task id: ${SGE_TASK_ID}"
#> 
#> ## Load the R module (absent since the JHPCE upgrade to CentOS v7)
#> module load conda_R
#> 
#> ## List current modules for reproducibility
#> module list
#> 
#> ## Edit with your job command
#> Rscript -e "options(width = 120); sessioninfo::session_info()"
#> 
#> echo "**** Job ends ****"
#> date
#> 
#> ## This script was made using sgejobs version 0.99.2
#> ## available from http://research.libd.org/sgejobs/
#> 

## An array job
job_single("jhpce_job_array", task_num = 20, create_logdir = FALSE)
#> #!/bin/bash
#> #$ -cwd
#> #$ -l mem_free=10G,h_vmem=10G,h_fsize=100G
#> #$ -N jhpce_job_array
#> #$ -o logs/jhpce_job_array.$TASK_ID.txt
#> #$ -e logs/jhpce_job_array.$TASK_ID.txt
#> #$ -m e
#> #$ -t 1-20
#> #$ -tc 20
#> 
#> echo "**** Job starts ****"
#> date
#> 
#> echo "**** JHPCE info ****"
#> echo "User: ${USER}"
#> echo "Job id: ${JOB_ID}"
#> echo "Job name: ${JOB_NAME}"
#> echo "Hostname: ${HOSTNAME}"
#> echo "Task id: ${SGE_TASK_ID}"
#> 
#> ## Load the R module (absent since the JHPCE upgrade to CentOS v7)
#> module load conda_R
#> 
#> ## List current modules for reproducibility
#> module list
#> 
#> ## Edit with your job command
#> Rscript -e "options(width = 120); sessioninfo::session_info()"
#> 
#> echo "**** Job ends ****"
#> date
#> 
#> ## This script was made using sgejobs version 0.99.2
#> ## available from http://research.libd.org/sgejobs/
#>