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 checkProfileProvided to utils_nfcore_pipeline #4891

Merged
merged 1 commit into from
Feb 9, 2024
Merged
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
18 changes: 18 additions & 0 deletions subworkflows/nf-core/utils_nfcore_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import nextflow.extension.FilesEx

workflow UTILS_NFCORE_PIPELINE {

take:
nextflow_cli_args

main:
valid_config = checkConfigProvided()
checkProfileProvided(nextflow_cli_args)

emit:
valid_config
Expand Down Expand Up @@ -43,6 +47,20 @@ def checkConfigProvided() {
return valid_config
}

//
// Exit pipeline if --profile contains spaces
//
def checkProfileProvided(nextflow_cli_args) {
if (workflow.profile.endsWith(',')) {
error "The `-profile` option cannot end with a trailing comma, please remove it and re-run the pipeline!\n" +
"HINT: A common mistake is to provide multiple values separated by spaces e.g. `-profile test, docker`.\n"
}
if (nextflow_cli_args[0]) {
log.warn "nf-core pipelines do not accept positional arguments. The positional argument `${nextflow_cli_args[0]}` has been detected.\n" +
"HINT: A common mistake is to provide multiple values separated by spaces e.g. `-profile test, docker`.\n"
}
}

//
// Citation string for pipeline
//
Expand Down
6 changes: 5 additions & 1 deletion subworkflows/nf-core/utils_nfcore_pipeline/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ keywords:
- initialise
- version
components: []
input: []
input:
- nextflow_cli_args:
type: list
description: |
Nextflow CLI positional arguments
output:
- success:
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ nextflow_function {
}
}

test("Test Function checkProfileProvided") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a test with a faulty input?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a way to provide a workflow.profile in the nf-test docs, nor how to check the content of the warning logging, so I'm not sure how to test a case of failure in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, maybe I am thinking too much in a pytest way. 🙂 Good as it is then


function "checkProfileProvided"

when {
function {
"""
input[0] = []
"""
}
}

then {
assertAll(
{ assert function.success },
{ assert snapshot(function.result).match() }
)
}
}

test("Test Function workflowCitation") {

function "workflowCitation"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ nextflow_workflow {

test("Should run without failures") {

when {
workflow {
"""
input[0] = []
"""
}
}

then {
assertAll(
{ assert workflow.success },
Expand Down
Loading