This repository has been archived by the owner on Jan 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Testing of object, map, and array literals #8
Open
jggatter
wants to merge
4
commits into
openwdl:master
Choose a base branch
from
jggatter:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
__pycache__ | ||
.DS_Store | ||
|
||
# cromwell jar files | ||
# cromwell jar files, etc. | ||
cromwell-executions | ||
cromwell-workflow-logs | ||
*.jar | ||
pytest-wdl-tests/tests/literals/run.sh | ||
pytest-wdl-tests/tests/literals/validate.sh | ||
pytest-wdl-tests/tests/literals/json.sh | ||
|
||
# python virtual environment | ||
env/ | ||
env/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
INTS | ||
0 | ||
1 | ||
2 | ||
STRINGS | ||
array | ||
literal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
INTS | ||
1 10 | ||
2 11 | ||
MIXED | ||
a 1 | ||
b 2 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
a b | ||
10 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
OBJECT_SYNTAX | ||
key1 key2 key3 | ||
7 8 9 | ||
MAP_COERCION | ||
key1name key2name key3name | ||
10 11 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
23 twenty-three |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
# This workflow tests the the literals sections of the WDL 1.0 Spec | ||
# It also requires the use of some functions such as write_lines(), write_object(), write_map(), and stdout() | ||
# write_map() is slightly broken as it does not print a \n after writing like the related functions do. | ||
|
||
version 1.0 | ||
|
||
workflow literals { | ||
input { | ||
### Array Literals | ||
Array[String] array_literal_strings = ["array", "literal"] | ||
Array[Int] array_literal_ints = [0, 1, 2] | ||
|
||
### Map Literals | ||
Map[Int, Int] map_literal_ints = {1: 10, 2: 11} | ||
Map[String, Int] map_literal_mixed = {"a": 1, "b": 2} | ||
|
||
### Object Literals | ||
Object object_literal = object { | ||
a: 10, | ||
b: 11 | ||
} | ||
|
||
### Object Coercion from Map | ||
# "object" keyword before {} indicates Object, absence of indicates Map. | ||
String key1 = "key1name" | ||
String key2 = "key2name" | ||
String key3 = "key3name" | ||
|
||
Object object_syntax = object { | ||
key1: 7, | ||
key2: 8, | ||
key3: 9 | ||
} | ||
|
||
Object map_coercion = { | ||
key1: 10, | ||
key2: 11, | ||
key3: 12 | ||
} | ||
|
||
### Pair Literals | ||
Pair[Int, String] pair_literal_mixed = (23, "twenty-three") | ||
} | ||
call array_literals { | ||
input: | ||
array_literal_strings=write_lines(array_literal_strings), | ||
array_literal_ints=write_lines(array_literal_ints) | ||
} | ||
call map_literals { | ||
input: | ||
map_literal_ints=write_map(map_literal_ints), | ||
map_literal_mixed=write_map(map_literal_mixed) | ||
} | ||
call object_literals { | ||
input: | ||
object_literal = write_object(object_literal) | ||
} | ||
call object_map_coercion { | ||
input: | ||
object_syntax=write_object(object_syntax), | ||
map_coercion=write_object(map_coercion) | ||
} | ||
call pair_literals { | ||
input: | ||
pair_literal_mixed_left=pair_literal_mixed.left, | ||
pair_literal_mixed_right=pair_literal_mixed.right | ||
} | ||
output { | ||
File array_literals_out = array_literals.array_literals_out | ||
File map_literals_out = map_literals.map_literals_out | ||
File object_literals_out = object_literals.object_literals_out | ||
File object_map_coercion_out = object_map_coercion.object_map_coercion_out | ||
File pair_literals_out = pair_literals.pair_literals_out | ||
} | ||
} | ||
|
||
task array_literals { | ||
input { | ||
File array_literal_ints | ||
File array_literal_strings | ||
} | ||
command { | ||
set -e | ||
echo INTS | ||
cat ~{array_literal_ints} | ||
printf "STRINGS\n" | ||
cat ~{array_literal_strings} | ||
} | ||
output { | ||
File array_literals_out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task map_literals { | ||
input { | ||
File map_literal_ints | ||
File map_literal_mixed | ||
} | ||
command { | ||
set -e | ||
|
||
echo INTS | ||
cat ~{map_literal_ints} | ||
printf "\nMIXED\n" # Need a newline following the first written map | ||
cat ~{map_literal_mixed} | ||
} | ||
output { | ||
File map_literals_out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task object_literals { | ||
input { | ||
File object_literal | ||
} | ||
command { | ||
set -e | ||
|
||
cat ~{object_literal} | ||
} | ||
output { | ||
File object_literals_out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task object_map_coercion { | ||
input { | ||
File object_syntax | ||
File map_coercion | ||
} | ||
command { | ||
set -e | ||
|
||
echo OBJECT_SYNTAX | ||
cat ~{object_syntax} | ||
printf "MAP_COERCION\n" | ||
cat ~{map_coercion} | ||
} | ||
output { | ||
File object_map_coercion_out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task pair_literals { | ||
input { | ||
Int pair_literal_mixed_left | ||
String pair_literal_mixed_right | ||
} | ||
command { | ||
set -e | ||
|
||
echo ~{pair_literal_mixed_left} ~{pair_literal_mixed_right} | ||
} | ||
output { | ||
File pair_literals_out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need this if the file is empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I deleted the jsons and the input dictionaries from every line in the python script and it gave me that error message. Any way around supplying inputs to py-test wdl? |
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
def test_literals(workflow_data, workflow_runner): | ||
expected = workflow_data.get_dict("array_literals_out", "map_literals_out", "object_literals_out", "object_map_coercion_out", "pair_literals_out") | ||
workflow_runner("literals.wdl", {}, expected, workflow_name="literals") |
164 changes: 164 additions & 0 deletions
164
pytest-wdl-tests/tests/stdlib/basic_array/basic_array.wdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
version 1.0 | ||
|
||
workflow basic_array_functions { | ||
input { | ||
File tsv | ||
Int num = 3 # range(num) --> [0, 1, 2] | ||
Array[Int] array_1 = [0, 1, 2] | ||
Array[Int] array_2 = [3, 4, 5] | ||
Array[String] array_3 = ['a', 'b', 'c'] | ||
Array[String] array_4 = ['d', 'e'] | ||
} | ||
# tsv is read into a 2D array before it is fed to transpose and flatten | ||
Array[Array[String]] array_2d = read_tsv(tsv) | ||
|
||
call range { | ||
input: array_range=range(num) | ||
} | ||
call transpose { | ||
input: array_transpose=transpose(array_2d) | ||
} | ||
scatter (pair in zip(array_1, array_3)) { | ||
call zip { | ||
input: | ||
pair_left=pair.left, | ||
pair_right=pair.right | ||
} | ||
} | ||
scatter (pair in cross(array_1, array_4)) { | ||
call cross { | ||
input: | ||
pair_left=pair.left, | ||
pair_right=pair.right | ||
} | ||
} | ||
call length { | ||
input: | ||
array_1_length=length(array_1), | ||
array_4_length=length(array_4) | ||
} | ||
call flatten { | ||
input: array_flatten=flatten(array_2d) | ||
} | ||
call prefix { | ||
input: array_prefix=prefix("prefix_", array_3) | ||
} | ||
output { | ||
File range_out = range.out | ||
File transpose_out = transpose.out | ||
Array[File] zip_out = zip.out | ||
Array[File] cross_out = cross.out | ||
File length_out = length.out | ||
File flatten_out = flatten.out | ||
File prefix_out = prefix.out | ||
} | ||
} | ||
|
||
task range { | ||
input { | ||
Array[Int] array_range | ||
} | ||
command { | ||
cat ~{write_lines(array_range)} | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task transpose { | ||
input { | ||
Array[Array[String]] array_transpose | ||
} | ||
command { | ||
cat ~{write_tsv(array_transpose)} | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task zip { | ||
input { | ||
Int pair_left | ||
String pair_right | ||
} | ||
command { | ||
echo ~{pair_left} ~{pair_right} | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task cross { | ||
input { | ||
Int pair_left | ||
String pair_right | ||
} | ||
command { | ||
echo ~{pair_left} ~{pair_right} | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task length { | ||
input { | ||
Int array_1_length | ||
Int array_4_length | ||
} | ||
command { | ||
echo ~{array_1_length} # 3 | ||
echo ~{array_4_length} # 2 | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task flatten { | ||
input { | ||
Array[String] array_flatten | ||
} | ||
command { | ||
cat ~{write_lines(array_flatten)} | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} | ||
|
||
task prefix { | ||
input { | ||
Array[String] array_prefix | ||
} | ||
command { | ||
cat ~{write_lines(array_prefix)} | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
runtime { | ||
docker: "ubuntu:latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
red blue yellow | ||
purple green orange |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you decided that you wanted to assert that there would be a newline added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put the newline in that WDL command so that Cromwell output would match this output file. If you're referring to lack of new line at the end of file, I don't know what's right, I just wanted write_map() to give a similar format to array's write_lines()