broadinstitute / wdl4s

Scala bindings for WDL
3 stars 5 forks source link

[Pregull] Input validation #235

Closed Horneth closed 7 years ago

Horneth commented 7 years ago

Implements logic to ingest a WDL or CWL input file and link the inputs to known WOM GraphInputNodes.

The logic is split this way: On the language side, each language provides a function to parse the input file however it wants, and returns a Map containing the inputs it found in the file. Keys are Strings. We expect their value to be the fullyQualifiedIdentifier of the GraphInputNode they intend to satisfy. Values are functions: WdlType => ErrorOr[WdlValue]. This is a bit weird, but it leaves to the language the ability to decide how (if possible) to coerce the value to the target type (defined by the graph input node) On the WOM side, in Executable, there is a validateInputs method that hands the input file to the language specific function described above. It then attempts for each GraphInputNode to find an entry in the returned map. Upon success, it calls the method (the value of the map entry) with the type the GraphInputNode says it is.

This indirection makes WOM able to ensure that all graph input nodes are looked for and treated the same way (w.r.t to optional values etc...) while leaving each language the flexibility to parse the input file how it pleases.


Aside from that, this PR also simplifies scatter and conditional nodes in WOM by removing their dependencies to all inputs of the inner graph. This should be discussed with @cjllanwarne when he's back

Horneth commented 7 years ago

@mcovarr this new commit should have less code duplication