def save_to_string(self, cmd: Command) -> str: inputs: List[CliArgument] = [*cmd.named] + ( [] if self.ignore_positionals else [*cmd.positional]) names = self.choose_variable_names(inputs) runtime = Task.Runtime() runtime.add_docker(cmd.docker_image) tool = Task( name=self.make_task_name(cmd), command=self.make_command(cmd, names), version="1.0", inputs=self.make_inputs(names), outputs=self.make_outputs(names), parameter_meta=self.make_parameter_meta(names), runtime=runtime, ) return tool.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