Skip to content

Make methods.get_cpus_and_memory more general #171

@zhuchcn

Description

@zhuchcn

The definition of the methods.get_cpus_and_memory function is too specific and should be converted to more general.

detect_cpus_and_memory = {
if (params.partition ==~ /F\d*/) {
def cpus = params.partition.replaceAll('F', '') as Integer
// F-series 1:2 CPU:memory ratio
def memory = 2 * cpus * 0.95 // 5% of memory is unavailable based on Slurm configuration
return ['cpus': cpus, 'memory': memory]
} else if (params.partition ==~ /M\d*/) {
def cpus = params.partition.replaceAll('M', '') as Integer
// M-series 1:16 CPU:memory ratio
def memory = 16 * cpus * 0.95 // %5 of memory is unavailable based on Slurm configuration
return ['cpus': cpus, 'memory': memory]
} else {
System.out.println("Failed to detect CPUs and memory for ${params.partition}. Using default values.")
return [:]
}
}

Options:

  1. Always require users to specify the number of cpus and memory per sample
  2. Use SLURM commands to get the number of cpus and memory per partition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions