-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- CromwellApi: added new methods for search, validate and abort - utils: added new past_date fxn to calculate a datetime in the past (or future) - metadata tests: add tests for keys on dicts, treating final states and non-final separately - new test files for: abort, validate, failures, search - new wdl directories: badFile, parseBatchFile
- Loading branch information
Showing
10 changed files
with
273 additions
and
10 deletions.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version 1.0 | ||
## This is a test workflow that fails against womtool. | ||
## From https://github.com/broadinstitute/cromwell | ||
#### WORKFLOW DEFINITION | ||
workflow oops { | ||
call oopsie | ||
} | ||
|
||
#### TASK DEFINITIONS | ||
task oopsie { | ||
input { | ||
String str | ||
} | ||
command { echo ${str} } | ||
runtime { docker: docker_image } | ||
} |
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,15 @@ | ||
# parseBatchFile WDL Workflow | ||
|
||
## Overview | ||
xxx | ||
|
||
## Workflow Components | ||
|
||
### Workflow: `parseBatchFile` | ||
xxx | ||
|
||
## Purpose | ||
To check Cromwell failures behavior | ||
|
||
## Version | ||
WDL 1.0 |
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,46 @@ | ||
version 1.0 | ||
# This workflow takes a tab separated file where each row is a set of data to be used in each | ||
# of the independent scattered task series that you have as your workflow process. This file | ||
# will, for example, have column names `sampleName`, `bamLocation`, and `bedlocation`. This | ||
# allows you to know that regardless of the order of the columns in your batch file, the correct | ||
# inputs will be used for the tasks you define. | ||
workflow parseBatchFile { | ||
input { | ||
File batchFile | ||
} | ||
Array[Object] batchInfo = read_objects(batchFile) | ||
scatter (job in batchInfo){ | ||
String sampleName = job.sampleName | ||
File bamFile = job.bamLocation | ||
File bedFile = job.bedLocation | ||
|
||
## INSERT YOUR WORKFLOW TO RUN PER LINE IN YOUR BATCH FILE HERE!!!! | ||
call test { | ||
input: in1=sampleName, in2=bamFile, in3=bedFile | ||
} | ||
|
||
} # End Scatter over the batch file | ||
# Outputs that will be retained when execution is complete | ||
output { | ||
Array[File] outputArray = test.item_out | ||
} | ||
# End workflow | ||
} | ||
|
||
#### TASK DEFINITIONS | ||
# echo some text to stdout, treats files as strings just to echo them as a dummy example | ||
task test { | ||
input { | ||
String in1 | ||
String in2 | ||
String in3 | ||
} | ||
command { | ||
echo ~{in1} | ||
echo ~{in2} | ||
echo ~{in3} | ||
} | ||
output { | ||
File item_out = stdout() | ||
} | ||
} |
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
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,13 @@ | ||
import pytest | ||
from utils import make_path | ||
|
||
wdls = ["helloHostname", "helloDockerHostname", "helloModuleHostname"] | ||
|
||
|
||
@pytest.mark.parametrize("wdl", wdls) | ||
def test_abort(cromwell_api, wdl): | ||
"""Checking that abort works""" | ||
workflow = cromwell_api.submit_workflow(wdl_path=make_path(wdl)) | ||
aborted = cromwell_api.abort(workflow["id"]) | ||
assert isinstance(aborted, dict) | ||
assert aborted["status"] == "Aborted" |
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,29 @@ | ||
# import re | ||
|
||
|
||
def test_failures_initial_state(cromwell_api, submit_wdls): | ||
"""Checking for failures works for initial state""" | ||
params = {"includeKey": "failures", "includeKey": "jobId"} | ||
fail = list(filter(lambda x: "parseBatchFile" in x["path"], submit_wdls)) | ||
res = cromwell_api.metadata(fail[0]["id"], params=params) | ||
assert isinstance(res, dict) | ||
assert res == {} | ||
|
||
|
||
# def test_failures_final_state(cromwell_api, submit_wdls): | ||
# """Checking for failures works for final state""" | ||
# params = {"includeKey": "failures", "includeKey": "jobId"} | ||
# fail = list(filter(lambda x: "parseBatchFile" in x["path"], submit_wdls)) | ||
# print(f"fail0: {fail[0]}") | ||
# res = cromwell_api.metadata(fail[0]["id"], params=params) | ||
# print(f"cromwell_api.metadata output:{res}") | ||
# fail_causedby_mssg = res["failures"]["causedBy"]["message"] | ||
# fail_mssg = res["failures"]["message"] | ||
# assert isinstance(res, dict) | ||
# assert list(res.keys()) == [ | ||
# "failures", | ||
# "calls", | ||
# "id", | ||
# ] | ||
# assert re.search("not specified", fail_causedby_mssg) is not None | ||
# assert re.search("failed", fail_mssg) is not None |
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
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,39 @@ | ||
import pytest | ||
|
||
search_result_each = [ | ||
"end", | ||
"id", | ||
"metadataArchiveStatus", | ||
"name", | ||
"start", | ||
"status", | ||
"submission", | ||
] | ||
|
||
|
||
# Check that search results are a subset as number of keys | ||
# can range from 4 to 7 depending on the item | ||
def contains_sublist(list1, list2): | ||
return set(list2).issubset(set(list1)) | ||
|
||
|
||
def test_search_no_results(cromwell_api): | ||
"""Checking that search works with no results""" | ||
out = cromwell_api.search(days=-2) | ||
# There should not be any results for a query for jobs | ||
# started in the future | ||
assert out["totalResultsCount"] == 0 | ||
assert out["results"] == [] | ||
|
||
|
||
def test_search_results(cromwell_api): | ||
"""Checking that search works when there MIGHT be results""" | ||
out = cromwell_api.search(days=1) | ||
# There may or may not be results, we can't gaurantee it | ||
if out["totalResultsCount"] == 0: | ||
pytest.skip("no results for search, skipping tests") | ||
else: | ||
assert isinstance(out["totalResultsCount"], int) | ||
assert len(out["results"]) > 0 | ||
for item in out["results"]: | ||
assert contains_sublist(search_result_each, list(item.keys())) |
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,20 @@ | ||
from utils import make_path | ||
|
||
|
||
def test_validate_good_wdl(cromwell_api): | ||
"""Checking that validate works - final state is quick""" | ||
res = cromwell_api.validate(wdl_path=make_path("helloHostname")) | ||
assert isinstance(res, dict) | ||
assert res["valid"] | ||
assert res["validWorkflow"] | ||
assert res["isRunnableWorkflow"] | ||
|
||
|
||
def test_validate_bad_wdl(cromwell_api): | ||
"""Checking that validate works - final state is quick""" | ||
res = cromwell_api.validate(wdl_path=make_path("badFile")) | ||
assert isinstance(res, dict) | ||
assert not res["valid"] | ||
assert not res["validWorkflow"] | ||
assert not res["isRunnableWorkflow"] | ||
assert "Cannot lookup value 'docker_image'" in res["errors"][0] |
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