Skip to content

Commit 71e973d

Browse files
committed
WDL test.
1 parent 0b7a707 commit 71e973d

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

test/test_integration.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def tearDown(self):
2626
time.sleep(3)
2727
except OSError as e:
2828
print(e)
29-
30-
shutil.rmtree('workflows')
29+
if os.path.exists('workflows'):
30+
shutil.rmtree('workflows')
3131
unittest.TestCase.tearDown(self)
3232

3333
def test_dockstore_md5sum(self):
@@ -72,6 +72,19 @@ def run_cwl_md5sum(cwl_input):
7272
return os.path.join(output_dir, 'md5sum.txt'), response['workflow_id']
7373

7474

75+
def run_wdl_md5sum(cwl_input):
76+
"""Pass a local md5sum wdl to the wes-service server, and return the path of the output file that was created."""
77+
endpoint = 'http://localhost:8080/ga4gh/wes/v1/workflows'
78+
params = '{"ga4ghMd5.inputFile": "' + os.path.abspath('testdata/md5sum.input') + '"}'
79+
parts = [("workflow_params", params),
80+
("workflow_type", "WDL"),
81+
("workflow_type_version", "v1.0"),
82+
("workflow_url", cwl_input)]
83+
response = requests.post(endpoint, files=parts).json()
84+
output_dir = os.path.abspath(os.path.join('workflows', response['workflow_id'], 'outdir'))
85+
return os.path.join(output_dir, 'md5sum.txt'), response['workflow_id']
86+
87+
7588
def get_log_request(run_id):
7689
endpoint = 'http://localhost:8080/ga4gh/wes/v1/workflows/{}'.format(run_id)
7790
return requests.get(endpoint).json()
@@ -124,6 +137,13 @@ def setUp(self):
124137
shell=True)
125138
time.sleep(5)
126139

140+
def test_wdl_md5sum(self):
141+
"""Pass a local md5sum cwl to the wes-service server, and check for the correct output."""
142+
cwl_local_path = os.path.abspath('testdata/md5sum.wdl')
143+
output_filepath, _ = run_wdl_md5sum(cwl_input=cwl_local_path)
144+
145+
self.assertTrue(check_for_file(output_filepath), 'Output file was not found: ' + str(output_filepath))
146+
127147

128148
# Prevent pytest/unittest's discovery from attempting to discover the base test class.
129149
del IntegrationTest

testdata/md5sum.wdl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
task md5 {
2+
File inputFile
3+
4+
command {
5+
/bin/my_md5sum ${inputFile}
6+
}
7+
8+
output {
9+
File value = "md5sum.txt"
10+
}
11+
12+
runtime {
13+
docker: "quay.io/briandoconnor/dockstore-tool-md5sum:1.0.4"
14+
cpu: 1
15+
memory: "512 MB"
16+
}
17+
}
18+
19+
workflow ga4ghMd5 {
20+
File inputFile
21+
call md5 { input: inputFile=inputFile }
22+
}

testdata/md5sum.wdl.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ga4ghMd5.inputFile": "md5sum.input"}

wes_service/toil_wes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def write_workflow(self, request, opts, wftype='cwl'):
5555
elif wftype == 'wdl':
5656
command_args = ['toil-wdl-runner'] + extra + [workflow_url, self.input_json]
5757
elif wftype == 'py':
58-
command_args = ['python'] + extra + [workflow_url]
58+
command_args = ['python'] + extra + [self.input_wf_filename]
5959
else:
6060
raise RuntimeError('workflow_type is not "cwl", "wdl", or "py": ' + str(wftype))
6161

@@ -261,14 +261,14 @@ def RunWorkflow(self):
261261
for k, ls in connexion.request.files.iterlists():
262262
for v in ls:
263263
if k == "workflow_descriptor":
264-
filename = secure_filename(v.filename)
264+
filename = secure_filename(os.path.basename(v.filename))
265265
v.save(os.path.join(tempdir, filename))
266+
body["workflow_url"] = "file:///%s/%s" % (tempdir, filename)
266267
elif k in ("workflow_params", "tags", "workflow_engine_parameters"):
267268
body[k] = json.loads(v.read())
268269
else:
269270
body[k] = v.read()
270271

271-
body["workflow_url"] = "file:///%s/%s" % (tempdir, body["workflow_url"])
272272
index = body["workflow_url"].find("http")
273273
if index > 0:
274274
body["workflow_url"] = body["workflow_url"][index:]

0 commit comments

Comments
 (0)