def test_readme_task(self): t = Task("task_name") t.inputs.append(Input(WdlType.parse_type("String"), "taskGreeting")) # command in next section t.outputs.append( Output(WdlType.parse_type("File"), "standardOut", "stdout()")) command = Task.Command("echo") command.inputs.append( Task.Command.CommandInput( "taskGreeting", optional=False, position=None, prefix="-a", separate_value_from_prefix=True, default=None, )) command.inputs.append( Task.Command.CommandInput( "otherInput", optional=True, position=2, prefix="optional-param=", separate_value_from_prefix=False, default=None, )) # t is the task t.command = command print(t.get_string())
def make_outputs(self, names: List[NamedArgument]) -> List[Output]: ret = [ # We default to always capturing stdout Output(data_type=File, name="out_stdout", expression="stdout()") ] for arg in names: typ = arg.arg.get_type() if isinstance(typ, cli_types.CliFileSystemType) and typ.output: ret.append( Output( data_type=self.type_to_wdl(typ), name="out_" + arg.name, expression='"${{in_{}}}"'.format(arg.name), )) return ret
def test_readme(self): w = Workflow("workflow_name") w.imports.append(Workflow.WorkflowImport("tool_file", "")) w.inputs.append(Input(WdlType.parse_type("String"), "inputGreeting")) inputs_map = {"taskGreeting": "inputGreeting"} w.calls.append( WorkflowCall("Q.namspaced_task_identifier", "task_alias", inputs_map)) w.outputs.append( Output(WdlType.parse_type("File"), "standardOut", "task_alias.standardOut")) print(w.get_string())
def test_simple_task(self): # Task based on: https://github.com/openwdl/wdl/blob/master/versions/draft-2/SPEC.md#introduction t = Task("hello", runtime=Task.Runtime(docker="broadinstitute/my_image")) t.inputs.extend([ Input(WdlType.parse_type("String"), "pattern"), Input(WdlType.parse_type("File"), "in"), ]) t.outputs.append( Output(WdlType.parse_type("Array[String]"), "matches", "read_lines(stdout())")) t.command = Task.Command( "egrep", inputs=[Task.Command.CommandInput.from_input(i) for i in t.inputs]) print(t.get_string()) return t
def test_hello_tasks(): # https://github.com/openwdl/wdl/#specifying-inputs-and-using-declarations t1 = Task( "hello", inputs=[Input(String, "name"), Input(String, "salutation")], outputs=[Output(String, "response", "read_string(stdout())")], ) t1.command = Task.Command( "echo", inputs=[ Task.Command.CommandInput.from_input(t1.inputs[i], position=i) for i in range(2) ], ) print(t1.get_string()) return t1