Open gudeqing opened 2 years ago
Indeed, the following workflow:
$ echo 'version development
workflow main {
input {
Directory d = "/etc"
}
}' > main.wdl
Will fail the womtool parser:
$ java -jar womtool-67.jar validate main.wdl
Failed to process workflow definition 'main' (reason 1 of 1): Failed to process input declaration 'Directory d = "/etc"' (reason 1 of 1): Cannot coerce expression of type 'String' to 'Directory'
Despite coercion from String
to Directory
being allowed by the WDL specification and this being among the examples (see here and here).
Surprisingly, you can coerce a String
into a Directory
if it comes from an input file:
$ echo 'version development
workflow main {
input {
Directory d
}
}' > main.wdl
$ echo '{
"main.d": "/etc"
}' > main.json
And then:
$ java -jar womtool-67.jar validate main.wdl -i main.json
Success!
Also puzzling is the following:
$ echo 'version development
workflow main {
input {
Directory d
}
String s = sub(d, "x", "y")
}' > main.wdl
And then:
$ java -jar womtool-67.jar validate main.wdl
Failed to process workflow definition 'main' (reason 1 of 1): Failed to process declaration 'String s = sub(d, "x", "y")' (reason 1 of 1): Failed to process expression 'sub(d, "x", "y")' (reason 1 of 1): Invalid parameter 'IdentifierLookup(d)'. Expected 'File' but got 'Directory'
First of all, it is unclear why womtool claims sub expects a File
, as the definition of sub is String sub(String, String, String)
so File
is not something that should be expected. Here it should be allowed to coerce Directory
to String
the same way as it is allowed to coerce File
to String
:
$ echo 'version development
workflow main {
input {
File f
}
String s = sub(f, "x", "y")
}' > main.wdl
And then:
$ java -jar womtool-67.jar validate main.wdl
Success!
Thanks, @freeseek , I see. Anyway, my solution is to make no default value for "Directory" input. From my own experiences, you should never expect WDL being perfect, haha.
Hi, I'm wondering what's the status here. We are bit by this and we really want to use Directory type because that saves a lot of troubles.
Without careful check, I'm wondering if it's just failed wom check and the String to Directory conversion actually works in Cromwell? If so, I'm wondering if this code is relevant and could partially fix the problem (not the sub
function I think) if WomUnlistedDirectoryType
is added to WomStringType
coercion targets.
Hi, I'm wondering what's the status here. We are bit by this and we really want to use Directory type because that saves a lot of troubles.
Without careful check, I'm wondering if it's just failed wom check and the String to Directory conversion actually works in Cromwell? If so, I'm wondering if this code is relevant and could partially fix the problem (not the
sub
function I think) ifWomUnlistedDirectoryType
is added toWomStringType
coercion targets.
Sorry for the random @ but may I get some eyes from contributors here? Just to see whether a simple fix on coercionMap
is meaningful and helpful? Happy to contribute with PR. Maybe @aednichols ?
Hi, can we define Directory in workflow input section? I met error "Cannot coerce expression of type 'String' to 'Directory'". my wdl file, cromwell 59 is used: