Skip to content

Commit 0f33378

Browse files
authored
Merge branch 'master' into master
2 parents 377cb18 + a5b0fc8 commit 0f33378

File tree

9 files changed

+67
-13
lines changed

9 files changed

+67
-13
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ install:
1313
script: tox
1414
notifications:
1515
email: false
16+
branches:
17+
only:
18+
- master

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Common workflow language tool description reference implementation
44

55
CWL Conformance test: |Build Status|
66

7+
Travis: |Unix Build Status|
8+
9+
.. |Unix Build Status| image:: https://img.shields.io/travis/common-workflow-language/cwltool/master.svg?label=unix%20build
10+
:target: https://travis-ci.org/common-workflow-language/cwltool
11+
712
This is the reference implementation of the Common Workflow Language. It is
813
intended to be feature complete and provide comprehensive validation of CWL
914
files as well as provide other tools related to working with CWL.

cwltool/load_tool.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424

2525
_logger = logging.getLogger("cwltool")
2626

27+
jobloaderctx = {
28+
u"cwl": "https://w3id.org/cwl/cwl#",
29+
u"path": {u"@type": u"@id"},
30+
u"location": {u"@type": u"@id"},
31+
u"format": {u"@type": u"@id"},
32+
u"id": u"@id"
33+
}
2734

2835
def fetch_document(argsworkflow, # type: Union[Text, dict[Text, Any]]
2936
resolver=None, # type: Callable[[Loader, Union[Text, dict[Text, Any]]], Text]
@@ -33,7 +40,7 @@ def fetch_document(argsworkflow, # type: Union[Text, dict[Text, Any]]
3340
# type: (...) -> Tuple[Loader, CommentedMap, Text]
3441
"""Retrieve a CWL document."""
3542

36-
document_loader = Loader({"cwl": "https://w3id.org/cwl/cwl#", "id": "@id"},
43+
document_loader = Loader(jobloaderctx,
3744
fetcher_constructor=fetcher_constructor)
3845

3946
uri = None # type: Text

cwltool/main.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from . import draft2tool, workflow
2323
from .cwlrdf import printdot, printrdf
2424
from .errors import UnsupportedRequirement, WorkflowException
25-
from .load_tool import fetch_document, make_tool, validate_document
25+
from .load_tool import fetch_document, make_tool, validate_document, jobloaderctx
2626
from .mutation import MutationManager
2727
from .pack import pack
2828
from .pathmapper import (adjustDirObjs, adjustFileObjs, get_listing,
@@ -424,13 +424,9 @@ def load_job_order(args, t, stdin, print_input_deps=False, relative_deps=False,
424424

425425
job_order_object = None
426426

427-
jobloaderctx = {
428-
u"path": {u"@type": u"@id"},
429-
u"location": {u"@type": u"@id"},
430-
u"format": {u"@type": u"@id"},
431-
u"id": u"@id"}
432-
jobloaderctx.update(t.metadata.get("$namespaces", {}))
433-
loader = Loader(jobloaderctx, fetcher_constructor=fetcher_constructor)
427+
_jobloaderctx = jobloaderctx.copy()
428+
_jobloaderctx.update(t.metadata.get("$namespaces", {}))
429+
loader = Loader(_jobloaderctx, fetcher_constructor=fetcher_constructor)
434430

435431
if len(args.job_order) == 1 and args.job_order[0][0] != "-":
436432
job_order_file = args.job_order[0]

cwltool/pathmapper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ def addLocation(d):
7777
if "basename" not in d:
7878
d["basename"] = os.path.basename(urllib.request.url2pathname(path))
7979

80+
if d["class"] == "File":
81+
d["nameroot"], d["nameext"] = os.path.splitext(d["basename"])
82+
8083
visit_class(job, ("File", "Directory"), addLocation)
8184

8285

tests/test_examples.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,16 @@ def loadref(base, p):
209209

210210
self.assertEquals([{
211211
"basename": "bar.cwl",
212+
"nameroot": "bar",
212213
"class": "File",
214+
"nameext": ".cwl",
213215
"location": "file:///example/bar.cwl"
214216
},
215217
{
216218
"basename": "data.txt",
219+
"nameroot": "data",
217220
"class": "File",
221+
"nameext": ".txt",
218222
"location": "file:///example/data.txt"
219223
},
220224
{
@@ -223,17 +227,23 @@ def loadref(base, p):
223227
"location": "file:///example/data2",
224228
"listing": [{
225229
"basename": "data3.txt",
230+
"nameroot": "data3",
226231
"class": "File",
232+
"nameext": ".txt",
227233
"location": "file:///example/data3.txt",
228234
"secondaryFiles": [{
229235
"class": "File",
230236
"basename": "data5.txt",
231-
"location": "file:///example/data5.txt"
237+
"location": "file:///example/data5.txt",
238+
"nameext": ".txt",
239+
"nameroot": "data5"
232240
}]
233241
}]
234242
}, {
235243
"basename": "data4.txt",
244+
"nameroot": "data4",
236245
"class": "File",
246+
"nameext": ".txt",
237247
"location": "file:///example/data4.txt"
238248
}], sc)
239249

@@ -245,7 +255,9 @@ def loadref(base, p):
245255

246256
self.assertEquals([{
247257
"basename": "bar.cwl",
258+
"nameroot": "bar",
248259
"class": "File",
260+
"nameext": ".cwl",
249261
"location": "file:///example/bar.cwl"
250262
}], sc)
251263

tests/test_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_updatedir(self):
124124
shutil.rmtree(tmp)
125125
shutil.rmtree(out)
126126

127-
def test_updateval_inplace(self):
127+
def test_updatedir_inplace(self):
128128
try:
129129
tmp = tempfile.mkdtemp()
130130
with open(os.path.join(tmp, "value"), "w") as f:

tests/test_pathmapper.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,30 @@ def test_strip_trailing(self):
2626
"basename": "bar"
2727
},
2828
d)
29+
30+
def test_basename_field_generation(self):
31+
base_file = {
32+
"class": "File",
33+
"location": "/foo/"
34+
}
35+
# (filename, expected: (nameroot, nameext))
36+
testdata = [
37+
("foo.bar", ("foo", ".bar")),
38+
("foo", ("foo", '')),
39+
(".foo", (".foo", '')),
40+
("foo.", ("foo", '.')),
41+
("foo.bar.baz", ("foo.bar", ".baz"))
42+
]
43+
44+
for filename, (nameroot, nameext) in testdata:
45+
file = dict(base_file)
46+
file["location"] = file["location"] + filename
47+
48+
expected = dict(file)
49+
expected["basename"] = filename
50+
expected["nameroot"] = nameroot
51+
expected["nameext"] = nameext
52+
53+
normalizeFilesDirs(file)
54+
self.assertEqual(file, expected)
55+

tests/wf/echo.cwl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ inputs:
55
script:
66
type: string
77
default: |
8+
from __future__ import print_function
89
import sys
9-
print sys.argv[1]
10+
print(sys.argv[1])
1011
if sys.argv[1] == "2":
1112
exit(1)
1213
else:
@@ -19,4 +20,4 @@ outputs:
1920
type: File
2021
outputBinding:
2122
glob: foo$(inputs.r).txt
22-
arguments: [python, -c, $(inputs.script), $(inputs.r)]
23+
arguments: [python, -c, $(inputs.script), $(inputs.r)]

0 commit comments

Comments
 (0)