Replacement for nf_core `check_max` function with new nextflow vscode extension

I’m wondering if anyone knows of a good replacement for this nf_core check_max() function that is compatible with the new nextflow language specification enforced by the vscode extension. Thanks!

I tried moving this function to WorkflowMain, but now i’m getting the following error when I run the pipeline

  error [groovy.lang.MissingMethodException]: No signature of method: groovy.util.ConfigObject.check_max() is applicable for argument types: (nextflow.script.ScriptBinding$ParamsMap, nextflow.util.Duration, String) values: [[input_annotation_id:null, input_baseline_id:null, input_run_name:null, sample_subset:null, ...], ...]

I define the function like this

class WorkflowMain {
    public static Object check_max(Map params, Object obj, String type) {...}
}

And i’m calling the function like this:

cpus = { WorkflowMain.check_max(params, 1 * task.attempt, 'cpus') }

I also tried a much simpler definition of the check_max function and it failed with the same error

class WorkflowMain {
    def check_max(params, obj, type) {...}
}

The check_max() function has been replaced by the resourceLimits directive.

See the Replace `check_max` with `resourceLimits` · Issue #2923 · nf-core/tools · GitHub

2 Likes

Thanks, this looks like close to what i need. I tried it out though and instead of reducing the resource requests to the limits it threw an error: “Process requirement exceeds available CPUs – req: 32; avail: 8”

@bentsherman ?

I believe the reason for this error is that there are still places in your pipeline code where you forgot to replace the old mechanism with resourceLimits. Can you share a minimal reproducible example?

Ah, the issue seems to be that i didn’t have brackets around the specification:

resourceLimits = { [cpus: params.max_cpus, memory: params.max_memory, time: params.max_time] }

Thanks!

1 Like