def test(): wdl_namespace = wdl.loads(wdl_code) wf = wdl_namespace.workflows[0] engine = Engine(wdl_run) engine.submit(Workflow(wf), {"inp": "README.md"}, "test") engine.run_all() assert engine.get("test").state == Job.FINISHED assert engine.jobs.vars["test.my_task.output"].endswith("output.txt")
def test_scatter_upstream_downstream(): wdl_namespace = wdl.loads(""" task t1 { File i String pattern command { grep '${pattern}' ${i} > "filtered" } output { File filtered = "filtered" } } task t2 { File i Array[String] s = ["a", "b", "c"] command { cat ${i} > out_file echo -e "${sep="\\n" s}" >> out_file } output { Array[String] strings = read_lines("out_file") } } task t3 { String x command {echo ${x}} output { String y = read_string(stdout()) } } workflow w { call t1 call t2 { input: i=t1.filtered } scatter(x in t2.strings) { call t3 { input: strings=x } } } """) call_t1 = wdl_namespace.resolve('w.t1') call_t2 = wdl_namespace.resolve('w.t2') call_t3 = wdl_namespace.resolve('w.t3') scatter = wdl_namespace.resolve('w._s7') assert call_t2.task.declarations[1].wdl_string() == 'Array[String] s = ["a", "b", "c"]' assert call_t1.name == 't1' assert call_t2.name == 't2' assert call_t3.name == 't3' assert scatter.name == '_s7' assert call_t1.upstream() == set() assert call_t2.upstream() == set([call_t1]) assert call_t3.upstream() == set([call_t2, scatter]) assert scatter.upstream() == set([call_t2]) assert call_t1.downstream() == set([call_t2]) assert call_t2.downstream() == set([call_t3, scatter]) assert call_t3.downstream() == set() assert scatter.downstream() == set([call_t3])
def test_fqn_and_upstream(): wdl_namespace = wdl.loads(""" task t1 { Int i Int j String foo = "bar" command { echo ${i+1} } output { Int o = read_int(stdout()) } } workflow w { call t1 call t1 as x {input: i=t1.o+10} call t1 as y {input: i=10+x.o, j=t1.o} } """) call_t1 = wdl_namespace.resolve('w.t1') call_x = wdl_namespace.resolve('w.x') call_y = wdl_namespace.resolve('w.y') assert call_t1.name == 't1' assert call_x.name == 'x' assert call_y.name == 'y' assert call_t1.upstream() == set() assert call_x.upstream() == set([call_t1]) assert call_y.upstream() == set([call_t1, call_x]) assert call_t1.downstream() == set([call_x, call_y]) assert call_x.downstream() == set([call_y]) assert call_y.downstream() == set() decl_i = wdl_namespace.resolve('w.t1.i') decl_i2 = wdl_namespace.resolve('w.t1.i') decl_j = wdl_namespace.resolve('w.x.j') decl_j2 = wdl_namespace.resolve('w.x.j') decl_foo = wdl_namespace.resolve('w.y.foo') assert decl_i.name == 'i' assert decl_i.type == WdlIntegerType() assert decl_i.expression == None assert decl_i2.name == 'i' assert decl_i2.type == WdlIntegerType() assert decl_i2.expression == None assert decl_j.name == 'j' assert decl_j.type == WdlIntegerType() assert decl_j.expression == None assert decl_j2.name == 'j' assert decl_j2.type == WdlIntegerType() assert decl_j2.expression == None assert decl_foo.name == 'foo' assert decl_foo.type == WdlStringType() assert decl_foo.expression.wdl_string() == '"bar"'
def test_beyond_scatter_upstream_downstream(): wdl_namespace = wdl.loads(""" task t1 { File i String pattern command { grep '${pattern}' ${i} > "filtered" } output { File filtered = "filtered" } } task t2 { File i Array[String] s = ["a", "b", "c"] command { cat ${i} > out_file echo -e "${sep="\\n" s}" >> out_file } output { Array[String] strings = read_lines("out_file") } } task t3 { String x command {echo ${x}} output { String y = read_string(stdout()) } } workflow w { call t1 call t2 { input: i=t1.filtered } Array[String] s = ["a", "b", "c"] scatter(n in s) { call t3 { input: x=t2.strings } } } """) call_t1 = wdl_namespace.resolve('w.t1') call_t2 = wdl_namespace.resolve('w.t2') call_t3 = wdl_namespace.resolve('w.t3') scatter = call_t3.parent assert call_t3.upstream() == set([call_t2, scatter])