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

Tests For write_map and read_map #9

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/test_map_serialization/main.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version 1.0
import "map_task.wdl" as map_wdl

workflow wf {
call map_wdl.make_test_cases as mk
Map[File, Int] map_int = {mk.files[0]: 1, mk.files[1]: 2, mk.files[2]: 3}
Map[File, Boolean] map_bool = {mk.files[0]: true, mk.files[1]: false, mk.files[2]: false}

call map_wdl.write_map as write_map {
input:
map_of_ints = map_int,
map_of_booleans = map_bool
}

call map_wdl.read_map

output {
File out_file_int = write_map.out1
File out_file_bool = write_map.out2
}
}
48 changes: 48 additions & 0 deletions tests/test_map_serialization/map_task.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version 1.0

task make_test_cases {
command {
}
output {
Array[String] files = ["f1", "f2", "f3"]
}
runtime {
docker: "python:3-slim"
}
}

task write_map {
input {
Map[String, Int] map_of_ints
Map[String, Boolean] map_of_booleans
# output files for each map type tests
String out_file_two = "./output_map_of_ints.txt"
String out_file_three = "./output_map_of_bools.txt"
}
command {
cat ${write_map(map_of_ints)} > ~{out_file_two}
cat ${write_map(map_of_booleans)} > ~{out_file_three}
}
output {
File out1 = out_file_two
File out2 = out_file_three
}
runtime {
docker: "python:3-slim"
}
}

task read_map {
command <<<
python3 <<CODE
map = {'x': 500, 'y': 600, 'z': 700}
print("\\n".join(["{}\\t{}".format(k,v) for k,v in map.items()]))
CODE
>>>
output {
Map[String, Int] out_map = read_map(stdout())
}
runtime {
docker: "python:3-slim"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
f1 alice
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file ever used?

f2 bob
f3 chuck
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
f1 true
f2 false
f3 false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
f1 1
f2 2
f3 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
f1 true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file looks like an output from a workflow run that can be deleted

f2 false
f3 false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
f1 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file looks like an output from a workflow run that can be deleted

f2 2
f3 3
8 changes: 8 additions & 0 deletions tests/test_map_serialization/tests/test_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"out_file_int": {
"name": "output_map_of_ints.txt"
},
"out_file_bool": {
"name": "output_map_of_bools.txt"
}
}
10 changes: 10 additions & 0 deletions tests/test_map_serialization/tests/test_map_serialization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def test_map_literal(workflow_data, workflow_runner):
expected = workflow_data.get_dict("out_file_int", "out_file_bool")
input={}
workflow_runner(
"../main.wdl",
input,
expected,
workflow_name="wf",
)

3 changes: 3 additions & 0 deletions tests/test_map_serialization/workflow_options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"final_workflow_outputs_dir": "./tests/test_map_serialization/tests/data/output_workflow"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file actually used?

}