|
| 1 | +includeConfig "../external/nextflow-config/config/retry/retry.config" |
1 | 2 |
|
2 | 3 | methods {
|
3 | 4 |
|
@@ -186,6 +187,44 @@ methods {
|
186 | 187 | }
|
187 | 188 | }
|
188 | 189 |
|
| 190 | + // Function to ensure that resource requirements don't go beyond |
| 191 | + // a maximum limit or below a minimum limit |
| 192 | + // needed for ../external/nextflow-config/config/retry/retry.config |
| 193 | + check_limits = { obj, type -> |
| 194 | + if (type == 'memory') { |
| 195 | + try { |
| 196 | + if (obj.compareTo(params.max_memory as nextflow.util.MemoryUnit) == 1) |
| 197 | + return params.max_memory as nextflow.util.MemoryUnit |
| 198 | + else if (obj.compareTo(params.min_memory as nextflow.util.MemoryUnit) == -1) |
| 199 | + return params.min_memory as nextflow.util.MemoryUnit |
| 200 | + else |
| 201 | + return obj |
| 202 | + } catch (all) { |
| 203 | + println " ### WARNING ### Max memory '${params.max_memory}' or min memory '${params.min_memory}' is not valid! Using default value: $obj" |
| 204 | + return obj |
| 205 | + } |
| 206 | + } else if (type == 'time') { |
| 207 | + try { |
| 208 | + if (obj.compareTo(params.max_time as nextflow.util.Duration) == 1) |
| 209 | + return params.max_time as nextflow.util.Duration |
| 210 | + else if (obj.compareTo(params.min_time as nextflow.util.Duration) == -1) |
| 211 | + return params.min_time as nextflow.util.Duration |
| 212 | + else |
| 213 | + return obj |
| 214 | + } catch (all) { |
| 215 | + println " ### WARNING ### Max time '${params.max_time}' or min time '${params.min_time}' is not valid! Using default value: $obj" |
| 216 | + return obj |
| 217 | + } |
| 218 | + } else if (type == 'cpus') { |
| 219 | + try { |
| 220 | + return Math.max( Math.min( obj, params.max_cpus as int ), params.min_cpus as int ) |
| 221 | + } catch (all) { |
| 222 | + println " ### WARNING ### Max cpus '${params.max_cpus}' or min cpus '${params.min_cpus}' is not valid! Using default value: $obj" |
| 223 | + return obj |
| 224 | + } |
| 225 | + } |
| 226 | + } |
| 227 | + |
189 | 228 | // Resource allocation here. Static node-based allocations included here
|
190 | 229 | set_resources_allocation = {
|
191 | 230 | // Function to ensure that resource requirements don't go beyond
|
@@ -263,5 +302,6 @@ methods {
|
263 | 302 | methods.set_pipeline_logs()
|
264 | 303 | methods.check_aligner()
|
265 | 304 | methods.set_resources_allocation()
|
| 305 | + retry.setup_retry() |
266 | 306 | }
|
267 | 307 | }
|
0 commit comments