nextflow
nextflow copied to clipboard
Configure errorStrategy and memory in a process using env vars.
Hi, I am trying to get this work:
withName:my_process {
container = "${env.MY_DOCKER_IMAGE}"
cpus = "${env.K8S_CPU}"
memory = { "${env.K8S_MEM_HIGH}" * task.attempt }
maxRetries = 3
errorStrategy = { (task.exitStatus in 137..140 && task.attempt <= 3) ? 'retry' : 'ignore' }
}
but currently have two issues:
- Memory.
memory = { "${env.K8S_MEM_HIGH}" * task.attempt }
does not work whether it is double quoted or not. It only seems to work if the base memory is hard coded, e.g.memory = { 100.MB * task.attempt }
. - MaxRetries. It looks like
maxRetries
cannot be reused inerrorStrategy
, e.g.(task.exitStatus in 137..140 && task.attempt <= maxRetries)
. In this case I do not get any error message or retry. The process just terminates with ignore.
Also, ideally, I would like to set maxRetries with an environment variable.
Could you help me figure out what I am doing wrong, please? I've tried so many combinations..
Thanks
This seems to work, although it is a bit cluttered.
withName:my_process {
container = "${env.MY_DOCKER_IMAGE}"
cpus = "${env.K8S_PROCESS_CPU}"
memory = { "${env.K8S_PROCESS_MEMORY_HIGH}" as int * 1.MB * task.attempt }
maxRetries = "${env.K8S_PROCESS_MAX_RETRIES}"
errorStrategy = { (task.exitStatus in 137..140 && task.attempt <= "${env.K8S_PROCESS_MAX_RETRIES}" as int) ? 'retry' : 'terminate' }
}
where:
K8S_PROCESS_MAX_RETRIES=3
K8S_PROCESS_MEMORY_HIGH=100
I think the solution you found is basically what you have to do. You might not have to wrap the environment variables, e.g. container = env.MY_DOCKER_IMAGE
. You can also leave out maxRetries
entirely, you don't really need it when using a custom error strategy like that.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.