Skip to content

Commit c17381e

Browse files
authored
Merge pull request #113 from common-workflow-language/formal_py3.6_support
Formal py3.6 support + fixes for toil
2 parents ab8a0f6 + 88e1afb commit c17381e

File tree

11 files changed

+220
-156
lines changed

11 files changed

+220
-156
lines changed

cwl_flask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class Job(threading.Thread):
1818
def __init__(self, jobid, path, inputobj):
19-
super(Job, self).__init__()
19+
super().__init__()
2020
self.jobid = jobid
2121
self.path = path
2222
self.inputobj = inputobj
@@ -108,7 +108,7 @@ def jobcontrol(jobid):
108108

109109

110110
def logspooler(job):
111-
with open(job.logname, "r") as f:
111+
with open(job.logname) as f:
112112
while True:
113113
r = f.read(4096)
114114
if r:

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
url="https://github.com/common-workflow-language/cwltool-service",
2121
download_url="https://github.com/common-workflow-language/cwltool-service",
2222
license="Apache 2.0",
23-
python_requires="~=3.5",
23+
python_requires="~=3.6",
2424
setup_requires=["pytest-runner"],
2525
tests_require=["pytest"],
2626
packages=["wes_service", "wes_client"],
@@ -53,6 +53,7 @@
5353
"Programming Language :: Python :: 3.6",
5454
"Programming Language :: Python :: 3.7",
5555
"Programming Language :: Python :: 3.8",
56+
"Programming Language :: Python :: 3.9",
5657
"Topic :: Software Development :: Libraries :: Python Modules",
5758
],
5859
)

test/test_client_util.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import subprocess
55
import sys
66

7-
pkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) # noqa
7+
pkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) # noqa
88
sys.path.insert(0, pkg_root) # noqa
99

1010
from wes_client.util import expand_globs, wf_info
@@ -15,42 +15,47 @@
1515
class IntegrationTest(unittest.TestCase):
1616
def setUp(self):
1717
dirname, filename = os.path.split(os.path.abspath(__file__))
18-
self.testdata_dir = dirname + 'data'
19-
self.local = {'cwl': 'file://' + os.path.join(os.getcwd() + '/testdata/md5sum.cwl'),
20-
'wdl': 'file://' + os.path.join(os.getcwd() + '/testdata/md5sum.wdl'),
21-
'py': 'file://' + os.path.join(os.getcwd() + '/test/test_integration.py'),
22-
'unsupported': 'fake.txt'}
18+
self.testdata_dir = dirname + "data"
19+
self.local = {
20+
"cwl": "file://" + os.path.join(os.getcwd() + "/testdata/md5sum.cwl"),
21+
"wdl": "file://" + os.path.join(os.getcwd() + "/testdata/md5sum.wdl"),
22+
"py": "file://" + os.path.join(os.getcwd() + "/test/test_integration.py"),
23+
"unsupported": "fake.txt",
24+
}
2325

2426
self.remote = {
25-
'cwl': 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.cwl',
26-
'wdl': 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.wdl',
27-
'py': 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/test/test_integration.py',
28-
'unsupported': 'gs://topmed_workflow_testing/topmed_aligner/small_test_files_sbg/example_human_known_snp.py',
29-
'unreachable': 'https://fake.py'}
30-
31-
self.expected = {'cwl': ('v1.0', 'CWL'),
32-
'wdl': ('draft-2', 'WDL'),
33-
'py': ('2.7', 'PY'),
34-
'pyWithPrefix': ('2.7', 'PY')}
27+
"cwl": "https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.cwl",
28+
"wdl": "https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.wdl",
29+
"py": "https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/test/test_integration.py",
30+
"unsupported": "gs://topmed_workflow_testing/topmed_aligner/small_test_files_sbg/example_human_known_snp.py",
31+
"unreachable": "https://fake.py",
32+
}
33+
34+
self.expected = {
35+
"cwl": ("v1.0", "CWL"),
36+
"wdl": ("draft-2", "WDL"),
37+
"py": ("2.7", "PY"),
38+
"pyWithPrefix": ("2.7", "PY"),
39+
}
3540

3641
def tearDown(self):
3742
unittest.TestCase.tearDown(self)
3843

3944
def test_expand_globs(self):
4045
"""Asserts that wes_client.expand_globs() sees the same files in the cwd as 'ls'."""
41-
files = subprocess.check_output(['ls', '-1', '.'])
46+
files = subprocess.check_output(["ls", "-1", "."])
4247

4348
# python 2/3 bytestring/utf-8 compatibility
4449
if isinstance(files, str):
45-
files = files.split('\n')
50+
files = files.split("\n")
4651
else:
47-
files = files.decode('utf-8').split('\n')
52+
files = files.decode("utf-8").split("\n")
4853

49-
if '' in files:
50-
files.remove('')
51-
files = ['file://' + os.path.abspath(f) for f in files]
52-
glob_files = expand_globs('*')
53-
assert set(files) == glob_files, '\n' + str(set(files)) + '\n' + str(glob_files)
54+
if "" in files:
55+
files.remove("")
56+
files = ["file://" + os.path.abspath(f) for f in files]
57+
glob_files = expand_globs("*")
58+
assert set(files) == glob_files, "\n" + str(set(files)) + "\n" + str(glob_files)
5459

5560
def testSupportedFormatChecking(self):
5661
"""
@@ -60,7 +65,7 @@ def testSupportedFormatChecking(self):
6065
"""
6166

6267
for file_format, location in self.local.items():
63-
if file_format != 'unsupported':
68+
if file_format != "unsupported":
6469
# Tests the behavior after receiving supported file types with and without the 'file://' prefix
6570
self.assertEqual(wf_info(location), self.expected[file_format])
6671
self.assertEqual(wf_info(location[7:]), self.expected[file_format])
@@ -78,20 +83,24 @@ def testFileLocationChecking(self):
7883
"""
7984

8085
for file_format, location in self.remote.items():
81-
if file_format == 'unsupported':
86+
if file_format == "unsupported":
8287
# Tests behavior after receiving a file hosted at an unsupported location.
8388
with self.assertRaises(NotImplementedError):
8489
wf_info(location)
8590

86-
elif file_format == 'unreachable':
91+
elif file_format == "unreachable":
8792
# Tests behavior after receiving a non-existent file.
8893
with self.assertRaises(IOError):
8994
wf_info(location)
9095

9196
else:
9297
self.assertEqual(wf_info(location), self.expected[file_format])
93-
self.assertFalse(os.path.isfile(os.path.join(os.getcwd(), 'fetchedFromRemote.' + file_format)))
98+
self.assertFalse(
99+
os.path.isfile(
100+
os.path.join(os.getcwd(), "fetchedFromRemote." + file_format)
101+
)
102+
)
94103

95104

96-
if __name__ == '__main__':
105+
if __name__ == "__main__":
97106
unittest.main() # run all tests

0 commit comments

Comments
 (0)