# Replacement for nf\_core \`check\_max\` function with new nextflow vscode extension

**URL:** <https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547>\
**Category:** Ask for help\
**Tags:** nextflow\
**Created:** [December 12, 2024, 10:02pm UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547 "2024-12-12T22:02:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sstrong99](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/sstrong99/32/188_2.png) [@sstrong99](https://community.seqera.io/u/sstrong99)\
**Post date:** [December 12, 2024, 10:02pm UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547/1 "2024-12-12T22:02:52Z")

</div>

I’m wondering if anyone knows of a good replacement for [this nf\_core check\_max() function](https://github.com/nf-core/atacseq/blob/1a1dbe52ffbd82256c941a032b0e22abbd925b8a/nextflow.config#L298) that is compatible with the new nextflow language specification enforced by the vscode extension. Thanks!

---

<div class="post-metadata">

**Author:** ![sstrong99](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/sstrong99/32/188_2.png) [@sstrong99](https://community.seqera.io/u/sstrong99)\
**Post date:** [December 13, 2024, 12:36am UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547/2 "2024-12-13T00:36:57Z")

</div>

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

```auto
  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

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

```

And i’m calling the function like this:

```auto
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

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

```

---

<div class="post-metadata">

**Author:** ![mahesh.binzerpanchal](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mahesh.binzerpanchal/32/253_2.png) [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Post date:** [December 13, 2024, 8:45am UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547/3 "2024-12-13T08:45:22Z")

</div>

The `check_max()` function has been replaced by the [resourceLimits directive](https://www.nextflow.io/docs/latest/reference/process.html#resourcelimits).

See the [Replace `check_max` with `resourceLimits` · Issue #2923 · nf-core/tools · GitHub](https://github.com/nf-core/tools/issues/2923)

---

<div class="post-metadata">

**Author:** ![sstrong99](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/sstrong99/32/188_2.png) [@sstrong99](https://community.seqera.io/u/sstrong99)\
**Post date:** [December 13, 2024, 8:18pm UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547/4 "2024-12-13T20:18:34Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![sstrong99](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/sstrong99/32/188_2.png) [@sstrong99](https://community.seqera.io/u/sstrong99)\
**Post date:** [December 18, 2024, 3:48pm UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547/5 "2024-12-18T15:48:44Z")

</div>

@bentsherman ?

---

<div class="post-metadata">

**Author:** ![mribeirodantas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mribeirodantas/32/235_2.png) [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Post date:** [December 19, 2024, 1:16am UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547/6 "2024-12-19T01:16:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sstrong99](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/sstrong99/32/188_2.png) [@sstrong99](https://community.seqera.io/u/sstrong99)\
**Post date:** [December 19, 2024, 1:57am UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547/7 "2024-12-19T01:57:19Z")

</div>

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

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

```

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/system/32/2402_2.png) [@system](https://community.seqera.io/u/system)\
**Post date:** [December 26, 2024, 1:58am UTC](https://community.seqera.io/t/replacement-for-nf-core-check-max-function-with-new-nextflow-vscode-extension/1547/8 "2024-12-26T01:58:09Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
