Update: July 26, 2019
This section of the forum is no longer actively monitored. We are working on a support migration plan that we will share here shortly. Apologies for this inconvenience.

WDL 1.0 won't let me call an optional task with an optional input

Example:

version 1.0

workflow my_workflow {
  input {
    File input_1
    File? input_2
  }

  call task1 {
    input:
      input_1 = input_1
  }

  if (defined(input_2)) {
    call task2 {
      input:
        input_2 = task1.output_1
    }
  }

  output {
    File output_1 = task1.output_1
    File? output_2 = task2.output_2
  }
}

task task1 {
  input {
    File input_1
  }
  command {
    echo "Hello, world!" > hello.txt
  }
  output {
    File output_1 = "hello.txt"
  }
}

task task2 {
  input {
    File input_2
  }
  command {
    cat ${input_2} > goodbye.txt
  }
  output {
    File output_2 = "goodbye.txt"
  }
}

Without declaring a version (and removing the input scopes), WOMtool validates this without complaint. As written, I get this error:

Failed to process workflow definition 'my_workflow' (reason 1 of 1): Failed to make call to 'task2' (reason 1 of 1): Failed to supply input input_2 = input_2 (reason 1 of 1): Cannot coerce expression of type 'File?' to 'File'

Is there a way to do the coercion in Cromwell? Or is my only alternative to declare input_2 as optional in task2, even though that's obviously nonsensical in context? Could I at least tweak task2 to fail hard if the "optional" input isn't actually specified?

Answers

Sign In or Register to comment.