From c17c1c2848266bc57ea10c59a96c2506101f1bc6 Mon Sep 17 00:00:00 2001 From: Matthieu Muffato Date: Mon, 26 Feb 2024 09:29:22 +0000 Subject: [PATCH] Fix for Nextflow 24.01-edge: functions have to be defined in the main nextflow.config https://github.com/nextflow-io/nextflow/issues/4722 --- conf/base.config | 27 --------------------------- nextflow.config | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/conf/base.config b/conf/base.config index b89dd1c7..fae443f1 100644 --- a/conf/base.config +++ b/conf/base.config @@ -4,33 +4,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -/* -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Increasing the number of CPUs often gives diminishing returns, so we increase it - following a logarithm curve. Example: - - 0 < value <= 1: start + step - - 1 < value <= 2: start + 2*step - - 2 < value <= 4: start + 3*step - - 4 < value <= 8: start + 4*step - In order to support re-runs, the step increase may be multiplied by the attempt - number prior to calling this function. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*/ - -// Modified logarithm function that doesn't return negative numbers -def positive_log(value, base) { - if (value <= 1) { - return 0 - } else { - return Math.log(value)/Math.log(base) - } -} - -def log_increase_cpus(start, step, value, base) { - return check_max(start + step * (1 + Math.ceil(positive_log(value, base))), 'cpus') -} - - process { errorStrategy = { task.exitStatus in ((130..145) + 104) ? 'retry' : 'finish' } diff --git a/nextflow.config b/nextflow.config index 529735e1..346afe1f 100644 --- a/nextflow.config +++ b/nextflow.config @@ -260,3 +260,30 @@ def check_max(obj, type) { } } } + +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Increasing the number of CPUs often gives diminishing returns, so we increase it + following a logarithm curve. Example: + - 0 < value <= 1: start + step + - 1 < value <= 2: start + 2*step + - 2 < value <= 4: start + 3*step + - 4 < value <= 8: start + 4*step + In order to support re-runs, the step increase may be multiplied by the attempt + number prior to calling this function. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +// Modified logarithm function that doesn't return negative numbers +def positive_log(value, base) { + if (value <= 1) { + return 0 + } else { + return Math.log(value)/Math.log(base) + } +} + +def log_increase_cpus(start, step, value, base) { + return check_max(start + step * (1 + Math.ceil(positive_log(value, base))), 'cpus') +} +