modules icon indicating copy to clipboard operation
modules copied to clipboard

Use `eval` to collect version

Open ewels opened this issue 1 year ago • 5 comments

Nextflow 24.02.0-edge brings with it two new features which should give much cleaner syntax for collecting tool versions: channel topics using topic (see https://github.com/nf-core/modules/issues/4517) and eval. They are designed to work together nicely, but are technically separate features.

  • Docs for eval: https://nextflow.io/docs/latest/process.html#output-type-eval
  • Blog post about eval and topic: https://nextflow.io/blog/2024/nextflow-2404-highlights.html#process-eval-outputs
  • Example pipeline change: https://github.com/nf-core/fetchngs/pull/312

The blog post contains a basic example of how this can be used to collect versions:

process FASTQC {
  input:
  tuple val(meta), path(reads)

  output:
  tuple val(meta), path('*.html'), emit: html
  tuple val("${task.process}"), val('fastqc'), eval('fastqc --version'), topic: versions 

  """
  fastqc $reads
  """
}

workflow {
  Channel.topic('versions') 
    | unique()
    | collectFile(name: 'collated_versions.yml')
    | CUSTOM_DUMPSOFTWAREVERSIONS
}

Needs some thought about how we approach these changes - may be best to do a bulk change everywhere in one go, as it affects multiple code locations (modules and pipelines).

ewels avatar Jun 19 '24 06:06 ewels

Nextflow 22.04 brings with it

Did you mean 24.04 ?

muffato avatar Jun 19 '24 08:06 muffato

See comment: https://github.com/nf-core/modules/issues/4517#issuecomment-2194150864

ewels avatar Jun 27 '24 08:06 ewels

Does this help fix #6696 ?

SPPearce avatar Oct 01 '24 12:10 SPPearce

An example that might need to be taken into consideration is that, in the nf-module for bwa, the command used to retrieve the version information is bwa 2>&1 and that command always returns exit code 1, and so I guess eval('bwa 2>&1') will always fail.

If the result of the version-retrieving command is pipped into sed like here, and the eval-statement over in the fastqc-module in the nf-core/repo would be something like eval('fastqc --version | sed \'/FastQC v/!d; s/.*v//'\')(Not sure about the syntax for escaping the single quotation mark (') but nevermind.), then Nextflow might not detect if the command fastqc --version | sed \'/FastQC v/!d; s/.*v//') has failed, because <some_failing_cmd> | sed '/FastQC v/!d; s/.*v//' seems to always return exit code 0.

asp8200 avatar Oct 01 '24 12:10 asp8200

Can we set pipefail globally? Is it already done?

SPPearce avatar Oct 01 '24 15:10 SPPearce