Hi folks, I'm writing an nf-test for a subworkflow...
# nf-test
g
Hi folks, I'm writing an nf-test for a subworkflow but it's failing on a process where I've included an input file as an output. Under normal conditions and when I run my workflow tests, this doesn't cause an issue so I assume it must be something about the way I've setup the test. I can see that the file is being successfully staged as a softlink and that file exists. Any suggestions for fixing it?
Subworkflow test:
Copy code
nextflow_workflow {

    name "Test Workflow GEL_INTERPRETATION_RD_WF"
    script "subworkflows/gel_interpretation_rd/main.nf"
    workflow "GEL_INTERPRETATION_RD_WF"


    test("Simple gel interpretation") {
        when {
            params {
                base_dir "$baseDir/tests/data/test_1"
                cohort = "test_cohort"
                gel_interpretation_cache_dir = "$baseDir/tests/data/test_1/cache_dir"
                gel_interpretation_configs = "test_interpretation"
                gel_interpretation_containers = "combined_tiering=combined_tiering.sif"
            }
            workflow {
                """
                input[0] = channel.fromList([
                    tuple([
                        [id:"case001"], 
                        file("$baseDir/tests/data/test_1/input/interpretation_requests/case001.interpretation_request.json"), 
                        [file("$baseDir/vcfs/case001.vcf.gz"), file("$baseDir/vcfs/case001.vcf.gz.tbi")],
                    ])
                ])
                """
            }
        }
        then {
            assert workflow.success
            //assert snapshot(workflow.out).match()
        }
    }
}
nf-test config:
Copy code
config {
    testsDir "tests"
    workDir ".nf-test"
    configFile "tests/nextflow.config"
    options "-stub-run"
}
Error message:
Copy code
Assertion failed:

  assert workflow.success
         |        |
         workflow false

  Nextflow stdout:

  [[id:case001], /Users/gabrielaldam/Projects/consolidate_abtiering/main/rd-tiering-ab-test/tests/data/test_1/input/interpretation_requests/case001.interpretation_request.json, [/Users/gabrielaldam/Projects/consolidate_abtiering/main/rd-tiering-ab-test/vcfs/case001.vcf.gz, /Users/gabrielaldam/Projects/consolidate_abtiering/main/rd-tiering-ab-test/vcfs/case001.vcf.gz.tbi]]
  ERROR ~ Error executing process > 'GEL_INTERPRETATION_RD_WF:RD_INTERPRETATION_COMBINED (case001.combined_tiering.test_interpretation)'

  Caused by:
    Missing output file(s) `case001.interpretation_request.json` expected by process `GEL_INTERPRETATION_RD_WF:RD_INTERPRETATION_COMBINED (case001.combined_tiering.test_interpretation)`
Failing process:
Copy code
process RD_INTERPRETATION_COMBINED {
    tag "${meta.id}.${meta.container_name}.${meta.interpretation_config_name}"

    container "${container.tiering}"

    input:
        tuple val(meta), path(interpretation_request), path(vcfs)
        tuple val(meta2), val(interpretation_config), val(container)
        path interpretation_cache_jsons

    output:
        tuple val(meta), path(interpretation_request), path(vcfs), emit: interpretation_request
        tuple val(meta), path("${meta.id}.interpreted_genome_rd.json"), emit: interpreted_genome
        tuple val(meta), val(interpretation_config), val(container), emit: interpretation_experiment
        tuple val(meta), path("pyspy.prof"), optional: true, emit: pyspyprof

    script:
    """
    ${params.gel_interpretation_python} ${projectDir}/bin/gel_interpretation_rd_combined.py \\
        --interpretation-request-path ${interpretation_request} \\
        --interpretation-config-path ${interpretation_config.path} \\
        --interpreted-genome-out-path ${meta.id}.interpreted_genome_rd.json
    """

    stub:
    """
    if [ "${params.gel_interpretation_python}" != "python3" ]; then
        echo "${meta.id}.${meta.container_name}.${meta.interpretation_config_name}" > pyspy.prof
    fi

    echo "${meta.id}.${meta.container_name}.${meta.interpretation_config_name}" > "${meta.id}.interpreted_genome_rd.json"
    """
}
n
Just to clarify, your workflow tests are also using the stub?
g
They are yes.
n
Ok, then I do not know what could be causing this...
😅 1
s
Can you try adding
includeInputs: true
in the process output? Like your
optional: true
g
Hmm, added:
Copy code
process RD_INTERPRETATION_COMBINED {
    tag "${meta.id}.${meta.container_name}.${meta.interpretation_config_name}"

    input:
        tuple val(meta), path(interpretation_request), path(vcfs)
        tuple val(meta2), val(interpretation_config), val(container)
        path interpretation_cache_jsons

    output:
        tuple val(meta), path(interpretation_request, includeInputs: true), path(vcfs, includeInputs: true), emit: interpretation_request
        tuple val(meta), path("${meta.id}.interpreted_genome_rd.json"), emit: interpreted_genome
        tuple val(meta), val(interpretation_config), val(container), emit: interpretation_experiment
        tuple val(meta), path("pyspy.prof"), optional: true, emit: pyspyprof
But same error:
Copy code
ERROR ~ Error executing process > 'GEL_INTERPRETATION_RD_WF:RD_INTERPRETATION_COMBINED (case001.combined_tiering.test_interpretation)'

  Caused by:
    Missing output file(s) `case001.interpretation_request.json` expected by process `GEL_INTERPRETATION_RD_WF:RD_INTERPRETATION_COMBINED (case001.combined_tiering.test_interpretation)`


  Work dir:
    /Users/gabrielaldam/Projects/consolidate_abtiering/main/rd-tiering-ab-test/.nf-test/tests/7659a6a0e0f3646117bcf86841a5a675/work/2d/26cd49c5b35c6d1b0579c8e17c6405
Files definitely exist:
Copy code
ll /Users/gabrielaldam/Projects/consolidate_abtiering/main/rd-tiering-ab-test/.nf-test/tests/7659a6a0e0f3646117bcf86841a5a675/work/2d/26cd49c5b35c6d1b0579c8e17c6405
total 4.0K
lrwxr-xr-x 1 gabrielaldam 158 Dec  1 15:36 case001.interpretation_request.json -> /Users/gabrielaldam/Projects/consolidate_abtiering/main/rd-tiering-ab-test/tests/data/test_1/input/interpretation_requests/case001.interpretation_request.json
-rw-r--r-- 1 gabrielaldam  45 Dec  1 15:36 case001.interpreted_genome_rd.json
lrwxr-xr-x 1 gabrielaldam  94 Dec  1 15:36 case001.vcf.gz -> /Users/gabrielaldam/Projects/consolidate_abtiering/main/rd-tiering-ab-test/vcfs/case001.vcf.gz
lrwxr-xr-x 1 gabrielaldam  98 Dec  1 15:36 case001.vcf.gz.tbi -> /Users/gabrielaldam/Projects/consolidate_abtiering/main/rd-tiering-ab-test/vcfs/case001.vcf.gz.tbi