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

workflow.container does not work in a DSL2 module #1758

Closed
sidorov-si opened this issue Oct 14, 2020 · 5 comments
Closed

workflow.container does not work in a DSL2 module #1758

sidorov-si opened this issue Oct 14, 2020 · 5 comments

Comments

@sidorov-si
Copy link

sidorov-si commented Oct 14, 2020

Bug report

workflow.container prints an empty map ([:]) instead of a container name if used in a DSL2 module.

Expected behavior and actual behavior

Print the name of the container used in a module, i. e. quay.io/biocontainers/fastqc:0.11.9--0 in the example below. Instead, it prints an empty dictionary ([:]).

Steps to reproduce the problem

DSL2 module (fastqc.nf):

#!/usr/bin/env nextflow

// Specify DSL2
nextflow.enable.dsl=2

// Process definition
process fastqc {

    container 'quay.io/biocontainers/fastqc:0.11.9--0'

    script:
    println("FastQC container: ${workflow.container}")
    """
    fastqc -v
    echo ${workflow.container}
    """
}

The main script that calls the module (main.nf, in the same directory as fastqc.nf):

#!/usr/bin/env nextflow

// Define DSL2
nextflow.enable.dsl=2

include { fastqc } from './fastqc.nf'

workflow {
    fastqc()
}

Config file (nextflow.config, in the same directory as fastqc.nf and main.nf):

docker.enabled = true

Command to run the example (invoke in the directory where the scripts are):

nextflow run main.nf

Program output

In .command.out:

FastQC v0.11.9
[:]

In stdout:

N E X T F L O W  ~  version 20.07.1
Launching `main.nf` [sleepy_gilbert] - revision: d301af5ec9
FastQC container: [:]
executor >  local (1)
[e8/3206f6] process > fastqc [100%] 1 of 1 ✔

Attached please find .nextflow.log

Environment

  • Nextflow version: 20.07.1.5412
  • Java version: "11.0.1" 2018-10-16 LTS
  • Operating system: macOS
  • Bash version: 3.2.57(1)-release (x86_64-apple-darwin17)

Additional context

I guess that workflow.container was introduced in DSL1 to report a container (or a dictionary of containers) from the whole pipeline. But in DSL2 it would be useful to be able to report names of containers from individual modules to log these names as part of a pipeline run summary.

@pditommaso
Copy link
Member

This is not a DSL2 specific issue. It also happens with

// Process definition
process fastqc {

    container 'bash'

    script:
    println("FastQC container: ${workflow.container}")
    """
    echo ${workflow.container}
    """
}

@KevinSayers
Copy link
Contributor

task.container gives the container for a specific process. This works, and is what you want to use.

workflow.container works if one container is specified for the entire workflow in config process.container= 'ubuntu'. There still is a bug if you specify more than one as below, then you still get the empty map.

process {
    withName: foo {
        container = 'ubuntu'
    }
    withName: bar {
        container = 'ubuntu'
    }
}

@stale
Copy link

stale bot commented Jul 18, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 18, 2021
@stale stale bot closed this as completed Sep 17, 2021
@pditommaso pditommaso reopened this Sep 17, 2021
@stale stale bot removed the stale label Sep 17, 2021
@stale
Copy link

stale bot commented Feb 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 16, 2022
@pditommaso
Copy link
Member

To access the container property in a reflective manner from the process itself, it should be used task.container. The property workflow.container is mean to collect the container used during the overall execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants