-
Notifications
You must be signed in to change notification settings - Fork 306
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
scatter over maps #106
Comments
Totally agree with this -- input in a ticket to be able to get map keys and values a while back. |
Just noticed this. I totally agree (and actually Cromwell already allows this so it's hopefully possible to just add to the spec and move straight to "implemented") |
eg in Cromwell you can do this: workflow foo {
Map[String, Int] map
scatter (pair in map) {
String key = pair.left
Int value = pair.right
}
output {
# Automatically gathered from inside the scatter:
Array[String] keys = key
Array[Int] values = value
}
} |
@cjllanwarne @geoffjentry is this something thats already supported as @cjllanwarne suggest? does it just need documentation? |
Yes, I opened that issue a year ago when such feature did not exist. Now it works, I will check docs, if docs are fine I will close this |
@cjllanwarne, this doesn't work on Cromwell v40. Could you take a look please? |
Just as a note here, the spec seems to specifaclly indicate the scattering can only be done over Arrays:
This seems to be the case for draft-2, 1.0 and development. |
@cjllanwarne @orodeh Here is the error I get on 38:
From this:
|
@DavyCats I read that as the expression must be coerceable to an array type. The coercion table (https://github.com/openwdl/wdl/blob/master/versions/1.0/SPEC.md#type-coercion) suggests Array[T] can accept an array-like type in which elements are coercible to T. Map elements should be coercible to Pair[K, V]. Indeed, in the definition of the flatten function, the WDL spec explicitly states "...Map[X, Y] can be coerced to Array[Pair[X, Y]]." |
@jdidion The comment under the flatten function indeed supports the notion that Maps are Array-like and its elements can be coerced to Pairs, but this comment seems wildly out of place. I don't believe the spec anywhere explicitly states that Maps are 'Array-like' (although I might be wrong). Array-like in the table refers to the various versions of list/array implementations in different programming languages, not to other types in WDL. ("The below table references String-like, Integer-like, etc to refer to values in a particular programming language.") There seems to be a discrepancy (or at least some unclearity/ambiguity) here. Please note that I have no issue with allowing coercion between Maps and Arrays, I just don't believe the 1.0 specs supports it. I actually added a number of functions to facilitate these coercions more explicilty in the developmental specs some time ago (#219). |
This is now solved by as_pairs and as_map functions in v1.1. |
Is there a workaround in the meantime for folks using v1.0? |
AFAIK Cromwell supports iteration over maps in WDL 1.0. But keep in mind that will not be portable to other implementations. |
Hmm, that will be great, but
gives |
Bump, this is still the case for v84. @jdidion any thoughts about @SHuang-Broad question about a workaround for 1.0? |
Bumping it again, supporting @gileshall comment for v85 |
still got this. |
@summerghw @ba3lwi just a note that this is not the Cromwell repo and the Cromwell team may not regularly look here. This was also not explicitly solved until v1.1 of wdl which Cromwell does not yet support. You are unlikely to get any support from them by commenting on this ticket. I would suggest you file a bug on their issue bird if you feel like this is a problem. Otherwise you could try using miniwdl check to see if it works? |
|
@patmagee thank you for reply. I use array(pair)slove the problom in wdl version 1.0. |
It would be nice to get methods to iterate over maps with scatter. It will also be good to have access to map.keySet and map.valueSet to be able to process keys or values of maps separately.
The text was updated successfully, but these errors were encountered: