Here's an example workflow that I think should work:
workflow testSub {
call MakeString{}
String no_and=sub(MakeString.out,"_and","")
}
task MakeString{
command{
echo hello_and_goodbye
}
runtime {
docker: "python:2.7"
memory: "1 GB"
}
output {
String out = read_string(stdout())
}
}
Running this however give the following error:
Workflow has invalid declarations: Could not evaluate workflow declarations: testSub.no_and: Invalid parameters for engine function sub: (Failure(wdl4s.exception.OutputVariableLookupException: Could not find outputs for call testSub.MakeString at index None),Success(WdlString(_and)),Success(WdlString())).
Which indicates (to me) that the function sub isn't waiting until the task MakeString runs and has an output, and then it errors out because it can't find one of its inputs...This is not the case for the function "size" for example, which will patiently wait until its inputs are ready.
This causes people to write workarounds that involve putting the sub command inside a subsequent task, piggybacking on the fact that the surrounding task will wait for the output...see for example (private repo) https://github.com/broadinstitute/dsde-pipelines/pull/323/files