Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resource labels to workflows. #21

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# demultiplex v0.1.2

## Minor updates

* Add resource labels to workflows (PR #21).

# demultiplex v0.1.1

## Minor updates
Expand Down
79 changes: 67 additions & 12 deletions src/config/labels.config
Original file line number Diff line number Diff line change
@@ -1,24 +1,79 @@
process {
// Default resources for components that hardly do any processing
memory = { 2.GB * task.attempt }
cpus = 1
container = 'nextflow/bash:latest'

// default resources
memory = { 8.Gb * task.attempt }
cpus = 8
maxForks = 36

// Retry for exit codes that have something to do with memory issues
errorStrategy = { task.exitStatus in 137..140 ? 'retry' : 'terminate' }
maxRetries = 3
maxMemory = null
maxMemory = 192.GB

// Resource labels
withLabel: singlecpu { cpus = 1 }
withLabel: lowcpu { cpus = 4 }
withLabel: midcpu { cpus = 10 }
withLabel: highcpu { cpus = 20 }
withLabel: verylowcpu { cpus = 2 }
withLabel: lowcpu { cpus = 8 }
withLabel: midcpu { cpus = 16 }
withLabel: highcpu { cpus = 32 }

withLabel: lowmem { memory = { get_memory( 4.GB * task.attempt ) } }
withLabel: midmem { memory = { get_memory( 25.GB * task.attempt ) } }
withLabel: highmem { memory = { get_memory( 50.GB * task.attempt ) } }
withLabel: veryhighmem { memory = { get_memory( 75.GB * task.attempt ) } }
withLabel: verylowmem { memory = { get_memory( 4.GB * task.attempt ) } }
withLabel: lowmem { memory = { get_memory( 8.GB * task.attempt ) } }
withLabel: midmem { memory = { get_memory( 16.GB * task.attempt ) } }
withLabel: highmem { memory = { get_memory( 64.GB * task.attempt ) } }

}

profiles {
// detect tempdir
tempDir = java.nio.file.Paths.get(
System.getenv('NXF_TEMP') ?:
System.getenv('VIASH_TEMP') ?:
System.getenv('TEMPDIR') ?:
System.getenv('TMPDIR') ?:
'/tmp'
).toAbsolutePath()

mount_temp {
docker.temp = tempDir
podman.temp = tempDir
charliecloud.temp = tempDir
}

no_publish {
process {
withName: '.*' {
publishDir = [
enabled: false
]
}
}
}

docker {
docker.fixOwnership = true
docker.enabled = true
// docker.userEmulation = true
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
}

local {
// This config is for local processing.
process {
maxMemory = 25.GB
withLabel: verylowcpu { cpus = 2 }
withLabel: lowcpu { cpus = 4 }
withLabel: midcpu { cpus = 6 }
withLabel: highcpu { cpus = 12 }

withLabel: lowmem { memory = { get_memory( 8.GB * task.attempt ) } }
withLabel: midmem { memory = { get_memory( 12.GB * task.attempt ) } }
withLabel: highmem { memory = { get_memory( 20.GB * task.attempt ) } }
}
}
}

def get_memory(to_compare) {
Expand Down
38 changes: 0 additions & 38 deletions src/config/tests.config

This file was deleted.

4 changes: 2 additions & 2 deletions src/demultiplex/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ viash ns build --setup cb

nextflow run . \
-main-script src/demultiplex/test.nf \
-profile docker,no_publish \
-profile docker,no_publish,local \
-entry test_wf \
-c src/config/tests.config \
-c src/config/labels.config \
--resources_test https://raw.githubusercontent.com/nf-core/test-datasets/demultiplex/testdata/NovaSeq6000/ \
-resume
5 changes: 5 additions & 0 deletions src/demultiplex/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ workflow run_wf {
samples_ch = input_ch
// untar input if needed
| untar.run(
directives: [label: ["lowmem", "lowcpu"]],
runIf: {id, state ->
def inputStr = state.input.toString()
inputStr.endsWith(".tar.gz") || \
Expand Down Expand Up @@ -38,6 +39,7 @@ workflow run_wf {
}

| interop_summary_to_csv.run(
directives: [label: ["lowmem", "verylowcpu"]],
fromState: [
"input": "input",
],
Expand All @@ -48,6 +50,7 @@ workflow run_wf {
)
// run bcl_convert
| bcl_convert.run(
directives: [label: ["highmem", "midcpu"]],
fromState: [
"bcl_input_directory": "input",
"sample_sheet": "sample_sheet",
Expand Down Expand Up @@ -89,6 +92,7 @@ workflow run_wf {
]
)
| falco.run(
directives: [label: ["lowcpu", "lowmem"]],
fromState: {id, state ->
reverse_fastqs_list = state.reverse_fastqs ? state.reverse_fastqs : []
[
Expand All @@ -104,6 +108,7 @@ workflow run_wf {
},
)
| multiqc.run(
directives: [label: ["lowcpu", "lowmem"]],
fromState: {id, state ->
[
"input": [
Expand Down