Skip to content
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

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

Open
mr-c opened this issue Aug 30, 2021 · 2 comments

Comments

@mr-c
Copy link
Contributor

mr-c commented Aug 30, 2021

Similar to common-workflow-lab/wdl-cwl-translator#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
Copy link
Member

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
Copy link
Contributor Author

mr-c commented Sep 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants