/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ebi-metagenomics/shallowmapping Nextflow base config file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    A 'blank slate' config file, appropriate for general use on most high performance
    compute environments. Assumes that all software is installed and available on
    the PATH. Runs in `local` mode - all jobs will be run on the logged in environment.
----------------------------------------------------------------------------------------
*/

process {

    resourceLimits = [
        cpus: params.max_cpus,
        memory: params.max_memory,
        time: params.max_time,
    ]

    cpus           = { 1 * task.attempt }
    memory         = { 6.GB * task.attempt }
    time           = { 4.h * task.attempt }

    errorStrategy  = { task.exitStatus in ((130..145) + 104) ? 'retry' : 'finish' }
    maxRetries     = 3
    maxErrors      = '-1'

    withLabel: process_single {
        cpus   = { 1 }
        memory = { 6.GB * task.attempt }
        time   = { 4.h * task.attempt }
    }
    withLabel: process_low {
        cpus   = { 2 * task.attempt }
        memory = { 12.GB * task.attempt }
        time   = { 4.h * task.attempt }
    }
    withLabel: process_medium {
        cpus   = { 6 * task.attempt }
        memory = { 36.GB * task.attempt }
        time   = { 8.h * task.attempt }
    }
    withLabel: process_high {
        cpus   = { 12 * task.attempt }
        memory = { 72.GB * task.attempt }
        time   = { 16.h * task.attempt }
    }
    withLabel: process_long {
        time = { 20.h * task.attempt }
    }
    withLabel: process_high_memory {
        memory = { 200.GB * task.attempt }
    }
    withLabel: error_ignore {
        errorStrategy = 'ignore'
    }
    withLabel: error_retry {
        errorStrategy = 'retry'
        maxRetries    = 2
    }
    withName: CUSTOM_DUMPSOFTWAREVERSIONS {
        cache = false
    }
}
