Skip to content

Commit 09e9eac

Browse files
committed
Merge branch 'wfInfoAdd' of github.com:bencvdb/workflow-service into wfInfoAdd
update dependencies
2 parents fecea8d + 5c364f9 commit 09e9eac

File tree

11 files changed

+388
-137
lines changed

11 files changed

+388
-137
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ python:
33
- '2.7'
44
before_install:
55
- sudo apt-get update -qq
6-
- virtualenv venv && . venv/bin/activate && git clone https://github.com/DataBiosphere/toil.git && cd toil && make prepare && make develop extras=[all] && cd ..
6+
- pip install toil[all]==3.17.0
77
- pip install . --process-dependency-links
88
- pip install -r dev-requirements.txt
99
script:

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ $ wes-server
2727
Note! All inputs files must be accessible from the filesystem.
2828

2929
```
30-
$ wes-client --host=localhost:8080 testdata/md5sum.cwl testdata/md5sum.cwl.json
30+
$ wes-client --host=localhost:8080 --proto=http --attachments="testdata/dockstore-tool-md5sum.cwl,testdata/md5sum.input" testdata/md5sum.cwl testdata/md5sum.cwl.json
3131
```
3232

3333
### List workflows
@@ -56,10 +56,17 @@ $ wes-client --proto http --host=locahost:8080 --log <workflow-id>
5656
$ wes-server --backend=wes_service.arvados_wes
5757
```
5858

59+
### Run a standalone server with Toil backend:
60+
61+
```
62+
$ pip install toil[all]
63+
$ wes-server --backend=wes_service.toil_wes --opt extra=--clean=never
64+
```
65+
5966
### Use a different executable with cwl_runner backend
6067

6168
```
62-
$ pip install toil
69+
$ pip install toil[all]
6370
$ wes-server --backend=wes_service.cwl_runner --opt runner=cwltoil --opt extra=--logLevel=CRITICAL
6471
```
6572

@@ -98,7 +105,14 @@ flags, `--host`, `--auth`, and `proto` respectively.
98105

99106
## Development
100107
If you would like to develop against `workflow-service` make sure you pass the provided test and it is flake8 compliant
101-
#### Run test
108+
109+
#### Install from Source
110+
111+
```
112+
$ virtualenv venv && source venv/bin/activate && pip install toil[all] && pip install . --process-dependency-links && pip install -r dev-requirements.txt
113+
```
114+
115+
#### Running Tests
102116
From path `workflow-service` run
103117

104118
```

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
long_description = readmeFile.read()
1212

1313
setup(name='wes-service',
14-
version='2.5',
14+
version='2.7',
1515
description='GA4GH Workflow Execution Service reference implementation',
1616
long_description=long_description,
1717
author='GA4GH Containers and Workflows task team',
@@ -25,7 +25,6 @@
2525
install_requires=[
2626
'future',
2727
'connexion==1.4.2',
28-
'bravado==10.1.0',
2928
'ruamel.yaml >= 0.12.4, < 0.15',
3029
'cwlref-runner==1.0',
3130
'schema-salad>=2.6, <3',

test/test_client_util.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from __future__ import absolute_import
2+
3+
import unittest
4+
import os
5+
import logging
6+
import subprocess
7+
8+
from wes_client.util import expand_globs
9+
10+
logging.basicConfig(level=logging.INFO)
11+
12+
13+
class IntegrationTest(unittest.TestCase):
14+
def setUp(self):
15+
dirname, filename = os.path.split(os.path.abspath(__file__))
16+
self.testdata_dir = dirname + 'data'
17+
18+
def tearDown(self):
19+
unittest.TestCase.tearDown(self)
20+
21+
def test_expand_globs(self):
22+
"""Asserts that wes_client.expand_globs() sees the same files in the cwd as 'ls'."""
23+
files = subprocess.check_output(['ls', '-1', '.'])
24+
25+
# python 2/3 bytestring/utf-8 compatibility
26+
if isinstance(files, str):
27+
files = files.split('\n')
28+
else:
29+
files = files.decode('utf-8').split('\n')
30+
31+
if '' in files:
32+
files.remove('')
33+
files = ['file://' + os.path.abspath(f) for f in files]
34+
glob_files = expand_globs('*')
35+
assert set(files) == glob_files, '\n' + str(set(files)) + '\n' + str(glob_files)
36+
37+
38+
if __name__ == '__main__':
39+
unittest.main() # run all tests

test/test_integration.py

Lines changed: 67 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
from __future__ import absolute_import
22

3-
import json
43
import unittest
54
import time
65
import os
76
import subprocess32 as subprocess
87
import signal
9-
import requests
108
import shutil
119
import logging
1210

13-
from wes_client.util import build_wes_request
11+
from wes_client.util import WESClient
1412

1513
logging.basicConfig(level=logging.INFO)
1614

@@ -30,6 +28,12 @@ def setUpClass(cls):
3028
cls.wdl_json_input = "file://" + os.path.abspath('testdata/md5sum.wdl.json')
3129
cls.wdl_attachments = ['file://' + os.path.abspath('testdata/md5sum.input')]
3230

31+
# client for the swagger API methods
32+
cls.client = WESClient({'auth': '', 'proto': 'http', 'host': 'localhost:8080'})
33+
34+
# manual test (wdl only working locally atm)
35+
cls.manual = False
36+
3337
def setUp(self):
3438
"""Start a (local) wes-service server to make requests against."""
3539
raise NotImplementedError
@@ -44,50 +48,74 @@ def tearDown(self):
4448
time.sleep(3)
4549
except OSError as e:
4650
print(e)
47-
# if os.path.exists('workflows'):
48-
# shutil.rmtree('workflows')
51+
if os.path.exists('workflows'):
52+
shutil.rmtree('workflows')
4953
unittest.TestCase.tearDown(self)
5054

5155
def test_dockstore_md5sum(self):
5256
"""HTTP md5sum cwl (dockstore), run it on the wes-service server, and check for the correct output."""
53-
outfile_path, _ = run_cwl_md5sum(cwl_input=self.cwl_dockstore_url,
54-
json_input=self.cwl_json_input,
55-
workflow_attachment=self.cwl_attachments)
57+
outfile_path, _ = self.run_md5sum(wf_input=self.cwl_dockstore_url,
58+
json_input=self.cwl_json_input,
59+
workflow_attachment=self.cwl_attachments)
5660
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
5761

5862
def test_local_md5sum(self):
5963
"""LOCAL md5sum cwl to the wes-service server, and check for the correct output."""
60-
outfile_path, run_id = run_cwl_md5sum(cwl_input=self.cwl_local_path,
61-
json_input=self.cwl_json_input,
62-
workflow_attachment=self.cwl_attachments)
64+
outfile_path, run_id = self.run_md5sum(wf_input=self.cwl_local_path,
65+
json_input=self.cwl_json_input,
66+
workflow_attachment=self.cwl_attachments)
6367
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
6468

6569
def test_run_attachments(self):
6670
"""LOCAL md5sum cwl to the wes-service server, check for attachments."""
67-
outfile_path, run_id = run_cwl_md5sum(cwl_input=self.cwl_local_path,
68-
json_input=self.cwl_json_input,
69-
workflow_attachment=self.cwl_attachments)
70-
get_response = get_log_request(run_id)["request"]
71+
outfile_path, run_id = self.run_md5sum(wf_input=self.cwl_local_path,
72+
json_input=self.cwl_json_input,
73+
workflow_attachment=self.cwl_attachments)
74+
get_response = self.client.get_run_log(run_id)["request"]
7175
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + get_response["workflow_attachment"])
7276
attachment_tool_path = get_response["workflow_attachment"][7:] + "/dockstore-tool-md5sum.cwl"
7377
self.assertTrue(check_for_file(attachment_tool_path), 'Attachment file was not found: ' + get_response["workflow_attachment"])
7478

79+
def test_get_service_info(self):
80+
"""
81+
Test wes_client.util.WESClient.get_service_info()
7582
76-
def run_cwl_md5sum(cwl_input, json_input, workflow_attachment=None):
77-
"""Pass a local md5sum cwl to the wes-service server, and return the path of the output file that was created."""
78-
endpoint = 'http://localhost:8080/ga4gh/wes/v1/runs'
79-
parts = build_wes_request(cwl_input,
80-
json_input,
81-
attachments=workflow_attachment)
82-
response = requests.post(endpoint, files=parts).json()
83-
assert 'run_id' in response, str(response.json())
84-
output_dir = os.path.abspath(os.path.join('workflows', response['run_id'], 'outdir'))
85-
return os.path.join(output_dir, 'md5sum.txt'), response['run_id']
83+
This method will exit(1) if the response is not 200.
84+
"""
85+
r = self.client.get_service_info()
86+
assert 'workflow_type_versions' in r
87+
assert 'supported_wes_versions' in r
88+
assert 'supported_filesystem_protocols' in r
89+
assert 'engine_versions' in r
8690

91+
def test_list_runs(self):
92+
"""
93+
Test wes_client.util.WESClient.list_runs()
8794
88-
def get_log_request(run_id):
89-
endpoint = 'http://localhost:8080/ga4gh/wes/v1/runs/{}'.format(run_id)
90-
return requests.get(endpoint).json()
95+
This method will exit(1) if the response is not 200.
96+
"""
97+
r = self.client.list_runs()
98+
assert 'workflows' in r
99+
100+
def test_get_run_status(self):
101+
"""
102+
Test wes_client.util.WESClient.run_status()
103+
104+
This method will exit(1) if the response is not 200.
105+
"""
106+
outfile_path, run_id = self.run_md5sum(wf_input=self.cwl_local_path,
107+
json_input=self.cwl_json_input,
108+
workflow_attachment=self.cwl_attachments)
109+
r = self.client.get_run_status(run_id)
110+
assert 'state' in r
111+
assert 'run_id' in r
112+
113+
def run_md5sum(self, wf_input, json_input, workflow_attachment=None):
114+
"""Pass a local md5sum cwl to the wes-service server, and return the path of the output file that was created."""
115+
response = self.client.run(wf_input, json_input, workflow_attachment)
116+
assert 'run_id' in response, str(response.json())
117+
output_dir = os.path.abspath(os.path.join('workflows', response['run_id'], 'outdir'))
118+
return os.path.join(output_dir, 'md5sum.txt'), response['run_id']
91119

92120

93121
def get_server_pids():
@@ -98,7 +126,7 @@ def get_server_pids():
98126
return pids
99127

100128

101-
def check_for_file(filepath, seconds=40):
129+
def check_for_file(filepath, seconds=120):
102130
"""Return True if a file exists within a certain amount of time."""
103131
wait_counter = 0
104132
while not os.path.exists(filepath):
@@ -130,21 +158,26 @@ def setUp(self):
130158
Start a (local) wes-service server to make requests against.
131159
Use toil as the wes-service server 'backend'.
132160
"""
133-
self.wes_server_process = subprocess.Popen('python {} --backend=wes_service.toil_wes --opt="extra=--logLevel=CRITICAL"'
161+
self.wes_server_process = subprocess.Popen('python {} --backend=wes_service.toil_wes '
162+
'--opt="extra=--logLevel=CRITICAL" '
163+
'--opt="extra=--clean=never"'
134164
''.format(os.path.abspath('wes_service/wes_service_main.py')),
135165
shell=True)
136166
time.sleep(5)
137167

138168
def test_local_wdl(self):
139169
"""LOCAL md5sum wdl to the wes-service server, and check for the correct output."""
140-
outfile_path, run_id = run_cwl_md5sum(cwl_input=self.wdl_local_path,
141-
json_input=self.wdl_json_input,
142-
workflow_attachment=self.wdl_attachments)
143-
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
170+
# Working locally but not on travis... >.<;
171+
if self.manual:
172+
outfile_path, run_id = self.run_md5sum(wf_input=self.wdl_local_path,
173+
json_input=self.wdl_json_input,
174+
workflow_attachment=self.wdl_attachments)
175+
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
144176

145177

146178
# Prevent pytest/unittest's discovery from attempting to discover the base test class.
147179
del IntegrationTest
148180

181+
149182
if __name__ == '__main__':
150183
unittest.main() # run all tests

0 commit comments

Comments
 (0)