WDL function select_first() is not handled
Closed this issue · 8 comments
Currently, the WDL function select_first() is not translated by the convertor. (https://github.com/openwdl/wdl/blob/main/versions/1.1/SPEC.md#x-select_firstarrayx)
A WDL workflow containing select_first() function can be found here. (https://github.com/biowdl/tasks/blob/develop/bwa.wdl#L82)
Is there a javascript equivalent for the WDL select_first()
function?
could I use the find
function?
Say, in the case of the example provided in (https://github.com/biowdl/tasks/blob/develop/bwa.wdl#L82):
memory: "~{select_first([memoryGb, estimatedMemoryGb])}G"
would be converted to
memory: "${[memoryGb, estimatedMemoryGb].find(mem => mem != None)}G"
Hi @Th3nn3ss
I think in JavaScript it would have to use strings ['memoryGb', 'estimatedMemoryGb']
, unless these two are variales declared previously. And the Python None
does not exist in JavaScript, so maybe test for null
and undefined
(or check if the None mentioned in the WDL spec should be treated differently in the wdl-cwl-translator.)
Bruno
Hi @Th3nn3ss
I think in JavaScript it would have to use strings
['memoryGb', 'estimatedMemoryGb']
, unless these two are variales declared previously. And the PythonNone
does not exist in JavaScript, so maybe test fornull
andundefined
(or check if the None mentioned in the WDL spec should be treated differently in the wdl-cwl-translator.)Bruno
OK.
The WDL documentation actually says it returns the first non-None
value of an Array
with optional values. So I have to find a way for a None
to be treated as a Javascript null
so it can return the appropriate error message when the expression isn't successful. Errors like error! array contains only None values
Hi @Th3nn3ss
I think in JavaScript it would have to use strings
['memoryGb', 'estimatedMemoryGb']
, unless these two are variales declared previously. And the PythonNone
does not exist in JavaScript, so maybe test fornull
andundefined
(or check if the None mentioned in the WDL spec should be treated differently in the wdl-cwl-translator.)Bruno
OK.
The WDL documentation actually says it returns the first non-None
value of anArray
with optional values. So I have to find a way for aNone
to be treated as a Javascriptnull
so it can return the appropriate error message when the expression isn't successful. Errors likeerror! array contains only None values
In this case the WDL None
will be a CWL/ECMAScript null
. Check the existing code in main.py
to see how null
/existence checks are currently handled.
Hi @Th3nn3ss
I think in JavaScript it would have to use strings
['memoryGb', 'estimatedMemoryGb']
, unless these two are variales declared previously. And the PythonNone
does not exist in JavaScript, so maybe test fornull
andundefined
(or check if the None mentioned in the WDL spec should be treated differently in the wdl-cwl-translator.)Bruno
memoryGb
is an optional input in this example, so it can be referred to as inputs.memoryGb
.
estimatedMemoryGb
is a "WDL declaration" that isn't bound to any input, so you may want to find another example or simplify the given example for testing.
Is this the required output
ramMin: ${[inputs.memoryGb].find(mem => mem !== null)}G