withLabel not applied in profiles scope

In nextflow.config, I have a profiles scope where several profiles are declared: localPC, localHPC, and grid. I defined some profile-specific process configs using withLabel, such as setting the maximum number of CPUs for processes having a specific label.

However, I’m finding that the withLabel declarations within the profiles do not have an effect. If I set withLabel: X {cpus = 10}, print(task.cpus) displays ‘1’ when called from the shell section of that process. By contrast, if I create a process scope and set cpus = 10 in nextflow.config, or set cpus = 10 in the process itself, then print(task.cpus) displays 10 as expected.

Is there a way to set the number of cpus using withLabel in a profile-specific manner?

Hello @bskubi

I can’t reproduce what you’re describing. I will share a minimal reproducible example so that you can try over there.

main.nf

process FOO {
  debug true
  label 'example'

  output:
  stdout

  script:
  """
    echo $task.cpus
    """
}

workflow { FOO() }

nextflow.config

profiles {
  ex {
    process {
      withLabel: example {
        cpus = 2
      }
    }
  }
  ex3 {
    process {
      withLabel: example {
        cpus = 3
      }
    }
  }
}

nextflow run main.nf -profile ex

 N E X T F L O W   ~  version 24.02.0-edge

 ┃ Launching `example.nf` [wise_rutherford] DSL2 - revision: 3ee838ca87

executor >  local (1)
[e5/e992f8] process > FOO [100%] 1 of 1 ✔
2

nextflow run main.nf

 N E X T F L O W   ~  version 24.02.0-edge

 ┃ Launching `example.nf` [sick_gutenberg] DSL2 - revision: 3ee838ca87

executor >  local (1)
[47/2e7e70] process > FOO [100%] 1 of 1 ✔
1

nextflow run main.nf -profile ex3

 N E X T F L O W   ~  version 24.02.0-edge

 ┃ Launching `example.nf` [awesome_bassi] DSL2 - revision: 3ee838ca87

executor >  local (1)
[bb/41ccde] process > FOO [100%] 1 of 1 ✔
3

Ah, I didn’t realize that withLabel still needed to be wrapped in a process scope within the per-profile scope, thank you! Might be worth mentioning in the documentation as there appears to be no example of using withLabel in a profile currently.

In the section for config profiles, you can see the directives are preceeded by process.. It’s equivalent to process { .. }. If you think that this is not enough, please open an issue on GitHub or a Pull Request with the changes you’d like for having it clearer.

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