broadinstitute / cromwell

Scientific workflow engine designed for simplicity & scalability. Trivially transition between one off use cases to massive scale production environments
http://cromwell.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
996 stars 361 forks source link

Enable global workflow variables inside tasks #2504

Open antonkulaga opened 7 years ago

antonkulaga commented 7 years ago

As far as I remember, in the Past it was possible to reference global workflow variables inside a task. But now I get wdl validation errors like this:

ERROR: Variable genome does not reference any declaration in the task (line 36, col 27):

    curl -z ${folder}"/"${genome} --max-time 10 --retry 3 --retry-delay 1 ${genomeURL}
                          ^

Task defined here (line 26, col 6):

task download_genome {

Here is the wdl

workflow indexes {

  File genomesFolder
  String version #release version
  String species #species and also name of the index/

  String releaseURL #path to releseas

  String transcriptome #relative file name (.fa.gz)
  String genome #relative file name (.fa.gz)
  String annotation #relative annotation file name (.gtf)

    call download_genome  {
    input:
         genomeURL = releaseURL + "/" + genome,
         transcriptomeURL = releaseURL + "/" + transcriptome,
         annotationURL = releaseURL + "/" + annotation,
         folder = genomesFolder + "/" + species + "/" + version
    }

}

task download_genome {

  String genomeURL
  String transcriptomeURL
  String annotationURL
  String folder

  command {
    mkdir -p ${folder}
    curl -z ${folder}"/"${genome} --max-time 10 --retry 3 --retry-delay 1 ${genomeURL}
    curl -z ${folder}"/"${transcriptome} --max-time 10 --retry 3 --retry-delay 1 ${transcriptomeURL}
    curl -z ${folder}"/"${annotation} --max-time 10 --retry 3 --retry-delay 1 ${annotationURL}
  }

}
mcovarr commented 7 years ago

I don't believe WDL ever allowed workflow declarations to be visible in tasks, but I'll label this as an enhancement request for our PO to review.

katevoss commented 7 years ago

@mcovarr is this related to #1335?

mcovarr commented 7 years ago

I don't think so, no.

brmyers commented 6 years ago

I'm a fan of this request. Perhaps something like ${workflowName.variableName} could be used within any task since it should be unique across the wdl file.

In the initial example (just to be explicit), the usage could look like: ${indexes.genome}

geoffjentry commented 6 years ago

@cjllanwarne is this a WOM issue or a WDL issue?

cjllanwarne commented 6 years ago

AFAIK this was never in the WDL spec so if Cromwell did allow it, it was probably a bug and therefore removed.

Having said that, something like allowing global values to be imported would be great - to add it, it'll need to be made as a WDL language addition, then we can support it in Cromwell (properly!)