feat: Add nf-core resource allocation parameters

This commit is contained in:
Thomas A. Christensen II 2023-09-25 18:05:10 -05:00
parent 137804518f
commit 7f43f0282f
Signed by: millironx
GPG key ID: 09335146883990B9

View file

@ -17,8 +17,34 @@ params {
}
process {
errorStrategy = 'finish'
time = '7d'
cpus = { check_max(1 * task.attempt, 'cpus') }
memory = { check_max(6.GB * task.attempt, 'memory') }
time = { check_max(4.h * task.attempt, 'time') }
errorStrategy = { task.exitStatus in ((130..145) + 104) ? 'retry' : 'finish' }
maxRetries = 1
maxErrors = '-1'
withLabel:process_single {
cpus = { check_max(1, 'cpus') }
memory = { check_max( 6.GB * task.attempt, 'memory') }
time = { check_max( 4.h * task.attempt, 'time') }
}
withLabel:process_low {
cpus = { check_max( 2 * task.attempt, 'cpus') }
memory = { check_max( 12.GB * task.attempt, 'memory') }
time = { check_max( 4.h * task.attempt, 'time') }
}
withLabel:process_medium {
cpus = { check_max( 6 * task.attempt, 'cpus') }
memory = { check_max( 36.GB * task.attempt, 'memory') }
time = { check_max( 8.h * task.attempt, 'time') }
}
withLabel:process_high {
cpus = { check_max( 12 * task.attempt, 'cpus') }
memory = { check_max( 72.GB * task.attempt, 'memory') }
time = { check_max( 16.h * task.attempt, 'time') }
}
withName: 'HAPLINK_ML_HAPLOTYPES' {
ext.ml_args = """
@ -41,3 +67,34 @@ env {
R_PROFILE_USER = "/.Rprofile"
R_ENVIRON_USER = "/.Renviron"
}
def check_max(obj, type) {
if (type == 'memory') {
try {
if (obj.compareTo(params.max_memory as nextflow.util.MemoryUnit) == 1)
return params.max_memory as nextflow.util.MemoryUnit
else
return obj
} catch (all) {
println " ### ERROR ### Max memory '${params.max_memory}' is not valid! Using default value: $obj"
return obj
}
} else if (type == 'time') {
try {
if (obj.compareTo(params.max_time as nextflow.util.Duration) == 1)
return params.max_time as nextflow.util.Duration
else
return obj
} catch (all) {
println " ### ERROR ### Max time '${params.max_time}' is not valid! Using default value: $obj"
return obj
}
} else if (type == 'cpus') {
try {
return Math.min( obj, params.max_cpus as int )
} catch (all) {
println " ### ERROR ### Max cpus '${params.max_cpus}' is not valid! Using default value: $obj"
return obj
}
}
}