// Nextflow config file for running on Google Cloud Life Sciences
params {
    gcp_region = 'us-central1'
    gcp_bucket = false
    gcp_debug = false
    gcp_preemptible = false
}

process {
    executor = 'google-lifesciences'

    // Defaults
    cpus = {params.max_cpus}
    memory = {8.GB * task.attempt}
    time = {60.m * task.attempt}
    errorStrategy = 'retry'
    maxRetries = params.max_retry
}

google {
    region = params.gcp_region
    lifeSciences {
        bootDiskSize = '50 GB'
        debug = params.gcp_debug
        preemptible = params.gcp_preemptible
    }
}

workDir = params.gcp_bucket
if (google.lifeSciences.preemptible) {
    process.errorStrategy = { task.exitStatus==14 ? 'retry' : 'terminate' }
    process.maxRetries = 5
}
