PMCC-BioinformaticsCore / janis-core

Core python modules for Janis Pipeline workflow assistant
GNU General Public License v3.0
4 stars 9 forks source link

fromwdl: missing optional inputs should result in empty conversion of WDL expressions, not half-empty strings with "null" inside #97

Open mr-c opened 3 years ago

mr-c commented 3 years ago

Similar to https://github.com/common-workflow-lab/wdl-cwl-translator/issues/80

https://github.com/openwdl/wdl/blob/main/versions/1.1/SPEC.md#expression-placeholder-coercion

If an expression within a placeholder evaluates to None, then the placeholder is replaced by the empty string.

Here is a test case

optional_inputs.wdl


version 1.0
task OptionalExample {
input {
Int? message
}
command {
   echo Hello ~{message}!
}

output {
File result = stdout()
}

runtime {
memory: "1 GiB"
}

}

produces the following

from datetime import datetime from typing import List, Optional, Dict, Any

from janis_core import * from janis_core.types.common_data_types import Int, File

Optionalexample_Dev = CommandToolBuilder( tool="OptionalExample", base_command=["sh", "script.sh"], inputs=[ ToolInput( tag="message", input_type=Int(optional=True), doc=InputDocumentation(doc=None), ) ], outputs=[ ToolOutput( tag="result", output_type=File(), selector=Stdout(subtype=File(), optional=False), doc=OutputDocumentation(doc=None), ) ], container="ubuntu:latest", version="DEV", memory=0.931323, disk=0.931323, files_to_create={ "script.sh": StringFormatter( "\n echo Hello {JANIS_WDL_TOKEN_1}!\n ", JANIS_WDL_TOKEN_1=InputSelector(input_to_select="message"), ) }, )

if name == "main":

or "cwl"

Optionalexample_Dev().translate("wdl")

Running this give us "Hello null!", while the original gives "Hello !"
illusional commented 3 years ago

From my initial glance, this sounds like is an issue with our CWL conversion (rather than the WDL ingestion), that we're allowing the empty value for CWL to stringify as 'null', right?

mr-c commented 3 years ago

From my initial glance, this sounds like is an issue with our CWL conversion (rather than the WDL ingestion), that we're allowing the empty value for CWL to stringify as 'null', right?

Depends on the semantics of InputSelector, but the empty value case does not seem to be defined: https://janis.readthedocs.io/en/latest/references/selectors.html?highlight=InputSelector#inputselector