New feature
Hi,
As discussed in nf-core's Slack, it would be helpful to be able to limit the resources used by a process launched with Apptainer or Singularity when using the local executor.
Use case
Currently, there is a discrepancy between Docker and Apptainer / Singularity engine behaviours when running a pipeline locally (already explained in Nextflow documentation). Although docker containers are limited in terms of cpu and memory (using the task's cpu and memory), apptainer / singularity containers can take up all available cpus and memory available on the host machine.
This can also be a problem during CI testing with apptainer, since the executor is local.
Suggested implementation
In line with what was proposed by @bentsherman , a solution could be to add flags like:
executor.$apptainer.memoryLimits
executor.$apptainer.cpuLimits
to pass task.cpus and task.memory values down to the container parameters.
Thanks a lot for all the hard work!