Skip to content

Warning about "brittle" output filepath definition should link to the documentation for how to avoid brittleness #650

@dvg-p4

Description

@dvg-p4

Part 1 of the "Hello nextflow" tutorial contains a basic example:

/*
 * Use echo to print 'Hello World!' to a file
 */
process sayHello {

    output:
        path 'output.txt'

    script:
    """
    echo 'Hello World!' > output.txt
    """
}

And then a warning:

This example is brittle because we hardcoded the output filename in two separate places (the script and the output blocks). If we change one but not the other, the script will break. Later, you'll learn how to use variables to avoid this problem.

However, it looks to me like the rest of the examples in the tutorial continue to use this exact same "brittle" pattern, with the script duplicating the output path defined under output. E.g. in Part 5:

#!/usr/bin/env nextflow

// Generate ASCII art with cowpy
process cowpy {

    publishDir 'results', mode: 'copy'

    input:
        path input_file
        val character

    output:
        path "cowpy-${input_file}"

    script:
    """
    cat $input_file | cowpy -c "$character" > cowpy-${input_file}
    """

}

cowpy-${input_file} is still manually written out twice in both the output and script blocks.

If there is in fact a suggested way to "use variables to avoid this problem", then it should be included in the tutorial and/or linked to from the warning message (such that those curious about it can see what the solution is.)

Or is the pattern in this later example, where the output path is dynamically generated from the input but with a still-hardcoded prefix, the sort of solution the warning was trying to refer to? If so, it would be nice to make that a bit more explicit.

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