Skip to content

Commit 1aad9c1

Browse files
authored
Merge branch 'master' into wilke/fix-pull-image
2 parents 9c11214 + 9b9131a commit 1aad9c1

File tree

110 files changed

+820
-13355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+820
-13355
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include tests/wf/*
99
include tests/override/*
1010
include tests/checker_wf/*
1111
include tests/subgraph/*
12+
include tests/trs/*
1213
include cwltool/schemas/v1.0/*.yml
1314
include cwltool/schemas/v1.0/*.yml
1415
include cwltool/schemas/v1.0/*.md

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ MODULE=cwltool
2727
# `[[` conditional expressions.
2828
PYSOURCES=$(wildcard ${MODULE}/**.py tests/*.py) setup.py
2929
DEVPKGS=pycodestyle diff_cover autopep8 pylint coverage pydocstyle flake8 \
30-
pytest pytest-xdist isort wheel
30+
pytest-xdist==1.27.0 isort wheel -rtest-requirements.txt
3131
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount \
3232
python-flake8 python-mock shellcheck
3333
VERSION=1.0.$(shell TZ=UTC git log --first-parent --max-count=1 \
@@ -51,7 +51,7 @@ help: Makefile
5151

5252
## install-dep : install most of the development dependencies via pip
5353
install-dep:
54-
pip install --upgrade $(DEVPKGS) -rtest-requirements.txt
54+
pip install --upgrade $(DEVPKGS)
5555

5656
## install-deb-dep: install most of the dev dependencies via apt-get
5757
install-deb-dep:

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ Running tests locally
498498

499499
- Running basic tests ``(/tests)``:
500500

501-
To run the basis tests after installing `cwltool` execute the following:
501+
To run the basic tests after installing `cwltool` execute the following:
502502

503503
.. code:: bash
504504

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ install:
3232
- ps: 'Install-Product node 0.12 x64'
3333
- "set PATH=%PYTHON%\\Scripts;%PATH%"
3434
- "%PYTHON%\\python.exe -m pip install -U pip setuptools^>=20.3 wheel"
35-
- "%PYTHON%\\python.exe -m pip install -U codecov pytest-xdist pytest-cov galaxy-lib -rtest-requirements.txt"
35+
- "%PYTHON%\\python.exe -m pip install -U codecov -rtest-requirements.txt pytest-xdist==1.27 "
3636
# Note the use of a `^` to escape the `>`
3737

3838
build_script:
3939
- "%PYTHON%\\python.exe -m pip install -rrequirements.txt"
40-
- "%PYTHON%\\python.exe -m pip install -e ."
40+
- "%PYTHON%\\python.exe -m pip install -e .[deps]"
4141

4242
test_script:
4343
- |

cwl-docker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
2+
# Changing the line below? Update https://cloud.docker.com/u/commonworkflowlanguage/repository/docker/commonworkflowlanguage/cwltool
23
exec docker run -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp -v "$PWD":"$PWD" -w="$PWD" commonworkflowlanguage/cwltool "$@"

cwltool/builder.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,16 @@ def bind_input(self,
207207
value_from_expression = False
208208
if "inputBinding" in schema and isinstance(schema["inputBinding"], MutableMapping):
209209
binding = CommentedMap(schema["inputBinding"].items())
210-
assert binding is not None
211210

212211
bp = list(aslist(lead_pos))
213212
if "position" in binding:
214-
bp.extend(aslist(binding["position"]))
213+
position = binding["position"]
214+
if isinstance(position, str): # no need to test the CWL Version
215+
# the schema for v1.0 only allow ints
216+
binding['position'] = self.do_eval(position, context=datum)
217+
bp.append(binding['position'])
218+
else:
219+
bp.extend(aslist(binding['position']))
215220
else:
216221
bp.append(0)
217222
bp.extend(aslist(tail_pos))
@@ -232,7 +237,6 @@ def bind_input(self,
232237
avsc = self.names.get_name(t["name"], "")
233238
if not avsc:
234239
avsc = make_avsc_object(convert_to_dict(t), self.names)
235-
assert avsc is not None
236240
if validate.validate(avsc, datum):
237241
schema = copy.deepcopy(schema)
238242
schema["type"] = t
@@ -373,7 +377,6 @@ def tostr(self, value): # type: (Any) -> Text
373377
# docker_req is none only when there is no dockerRequirement
374378
# mentioned in hints and Requirement
375379
path = docker_windows_path_adjust(value["path"])
376-
assert path is not None
377380
return path
378381
return value["path"]
379382
else:
@@ -418,8 +421,7 @@ def generate_arg(self, binding): # type: (Dict[Text, Any]) -> List[Text]
418421
if sep:
419422
args.extend([prefix, self.tostr(j)])
420423
else:
421-
assert prefix is not None
422-
args.append(prefix + self.tostr(j))
424+
args.append("" if not prefix else prefix + self.tostr(j))
423425

424426
return [a for a in args if a is not None]
425427

cwltool/command_line_tool.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def __init__(self,
9797

9898
def run(self, runtimeContext): # type: (RuntimeContext) -> None
9999
try:
100+
normalizeFilesDirs(self.builder.job)
100101
ev = self.builder.do_eval(self.script)
101102
normalizeFilesDirs(ev)
102103
self.output_callback(ev, "success")
@@ -156,7 +157,8 @@ def revmap_file(builder, outdir, f):
156157
if "basename" not in f:
157158
f["basename"] = os.path.basename(path)
158159

159-
assert builder.pathmapper is not None
160+
if not builder.pathmapper:
161+
raise ValueError("Do not call revmap_file using a builder that doesn't have a pathmapper.")
160162
revmap_f = builder.pathmapper.reversemap(path)
161163

162164
if revmap_f and not builder.pathmapper.mapper(revmap_f[0]).type.startswith("Writable"):
@@ -203,7 +205,8 @@ def check_adjust(builder, file_o):
203205
doesn't reach everything in builder.bindings
204206
"""
205207

206-
assert builder.pathmapper is not None
208+
if not builder.pathmapper:
209+
raise ValueError("Do not call check_adjust using a builder that doesn't have a pathmapper.")
207210
file_o["path"] = docker_windows_path_adjust(
208211
builder.pathmapper.mapper(file_o["location"])[1])
209212
dn, bn = os.path.split(file_o["path"])
@@ -299,7 +302,7 @@ def job(self,
299302
if runtimeContext.cachedir and enableReuse:
300303
cachecontext = runtimeContext.copy()
301304
cachecontext.outdir = "/out"
302-
cachecontext.tmpdir = "/tmp"
305+
cachecontext.tmpdir = "/tmp" # nosec
303306
cachecontext.stagedir = "/stage"
304307
cachebuilder = self._init_job(job_order, cachecontext)
305308
cachebuilder.pathmapper = PathMapper(cachebuilder.files,
@@ -353,7 +356,8 @@ def job(self,
353356

354357
keydictstr = json_dumps(keydict, separators=(',', ':'),
355358
sort_keys=True)
356-
cachekey = hashlib.md5(keydictstr.encode('utf-8')).hexdigest()
359+
cachekey = hashlib.md5( # nosec
360+
keydictstr.encode('utf-8')).hexdigest()
357361

358362
_logger.debug("[job %s] keydictstr is %s -> %s", jobname,
359363
keydictstr, cachekey)
@@ -476,24 +480,24 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
476480
if self.tool.get("stdin"):
477481
with SourceLine(self.tool, "stdin", validate.ValidationException, debug):
478482
j.stdin = builder.do_eval(self.tool["stdin"])
479-
assert j.stdin is not None
480-
reffiles.append({"class": "File", "path": j.stdin})
483+
if j.stdin:
484+
reffiles.append({"class": "File", "path": j.stdin})
481485

482486
if self.tool.get("stderr"):
483487
with SourceLine(self.tool, "stderr", validate.ValidationException, debug):
484488
j.stderr = builder.do_eval(self.tool["stderr"])
485-
assert j.stderr is not None
486-
if os.path.isabs(j.stderr) or ".." in j.stderr:
487-
raise validate.ValidationException(
488-
"stderr must be a relative path, got '%s'" % j.stderr)
489+
if j.stderr:
490+
if os.path.isabs(j.stderr) or ".." in j.stderr:
491+
raise validate.ValidationException(
492+
"stderr must be a relative path, got '%s'" % j.stderr)
489493

490494
if self.tool.get("stdout"):
491495
with SourceLine(self.tool, "stdout", validate.ValidationException, debug):
492496
j.stdout = builder.do_eval(self.tool["stdout"])
493-
assert j.stdout is not None
494-
if os.path.isabs(j.stdout) or ".." in j.stdout or not j.stdout:
495-
raise validate.ValidationException(
496-
"stdout must be a relative path, got '%s'" % j.stdout)
497+
if j.stdout:
498+
if os.path.isabs(j.stdout) or ".." in j.stdout or not j.stdout:
499+
raise validate.ValidationException(
500+
"stdout must be a relative path, got '%s'" % j.stdout)
497501

498502
if debug:
499503
_logger.debug(u"[job %s] command line bindings is %s", j.name,
@@ -546,7 +550,7 @@ def register_reader(f):
546550
adjustDirObjs(builder.files, register_reader)
547551
adjustDirObjs(builder.bindings, register_reader)
548552

549-
timelimit, _ = self.get_requirement("TimeLimit")
553+
timelimit, _ = self.get_requirement("ToolTimeLimit")
550554
if timelimit is not None:
551555
with SourceLine(timelimit, "timelimit", validate.ValidationException, debug):
552556
j.timelimit = builder.do_eval(timelimit["timelimit"])
@@ -592,12 +596,17 @@ def collect_output_ports(self,
592596
ports, # type: Set[Dict[Text, Any]]
593597
builder, # type: Builder
594598
outdir, # type: Text
599+
rcode, # type: int
595600
compute_checksum=True, # type: bool
596601
jobname="", # type: Text
597602
readers=None # type: Dict[Text, Any]
598603
): # type: (...) -> OutputPorts
599604
ret = {} # type: OutputPorts
600605
debug = _logger.isEnabledFor(logging.DEBUG)
606+
cwl_version = self.metadata.get(
607+
"http://commonwl.org/cwltool#original_cwlVersion", None)
608+
if cwl_version != "v1.0":
609+
builder.resources["exitCode"] = rcode
601610
try:
602611
fs_access = builder.make_fs_access(outdir)
603612
custom_output = fs_access.join(outdir, "cwl.output.json")
@@ -706,14 +715,13 @@ def collect_output(self,
706715
if ll and ll != "no_listing":
707716
get_listing(fs_access, files, (ll == "deep_listing"))
708717
else:
709-
with fs_access.open(rfile["location"], "rb") as f:
710-
contents = b""
711-
if binding.get("loadContents") or compute_checksum:
712-
contents = content_limit_respected_read_bytes(f)
713-
if binding.get("loadContents"):
714-
files["contents"] = contents.decode("utf-8")
715-
if compute_checksum:
716-
checksum = hashlib.sha1()
718+
if binding.get("loadContents"):
719+
with fs_access.open(rfile["location"], "rb") as f:
720+
files["contents"] = content_limit_respected_read_bytes(f).decode("utf-8")
721+
if compute_checksum:
722+
with fs_access.open(rfile["location"], "rb") as f:
723+
checksum = hashlib.sha1() # nosec
724+
contents = f.read(1024 * 1024)
717725
while contents != b"":
718726
checksum.update(contents)
719727
contents = f.read(1024 * 1024)

cwltool/cwlrdf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def printrdf(wflow, ctx, style): # type: (Process, ContextType, Text) -> Text
2727
rdf = gather(wflow, ctx).serialize(format=style, encoding='utf-8')
2828
if not rdf:
2929
return u""
30-
assert rdf is not None
3130
return rdf.decode('utf-8')
3231

3332

cwltool/docker.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def get_image(docker_requirement, # type: Dict[Text, Text]
155155
else:
156156
loadproc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
157157
stdout=sys.stderr)
158-
assert loadproc.stdin is not None
158+
assert loadproc.stdin is not None # nosec
159159
_logger.info(u"Sending GET request to %s", docker_requirement["dockerLoad"])
160160
req = requests.get(docker_requirement["dockerLoad"], stream=True)
161161
size = 0
@@ -259,7 +259,7 @@ def add_writable_directory_volume(self,
259259
self.append_volume(runtime, new_dir, volume.target,
260260
writable=True)
261261
elif not os.path.exists(host_outdir_tgt):
262-
os.makedirs(host_outdir_tgt, 0o0755)
262+
os.makedirs(host_outdir_tgt)
263263
else:
264264
if self.inplace_update:
265265
self.append_volume(runtime, volume.resolved, volume.target,
@@ -296,7 +296,8 @@ def create_runtime(self,
296296
runtime = [u"docker", u"run", u"-i"]
297297
self.append_volume(runtime, os.path.realpath(self.outdir),
298298
self.builder.outdir, writable=True)
299-
self.append_volume(runtime, os.path.realpath(self.tmpdir), "/tmp",
299+
tmpdir = "/tmp" # nosec
300+
self.append_volume(runtime, os.path.realpath(self.tmpdir), tmpdir,
300301
writable=True)
301302
self.add_volumes(self.pathmapper, runtime, any_path_okay=True,
302303
secret_store=runtimeContext.secret_store,

cwltool/executors.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ def run_jobs(self,
167167
self.output_dirs.add(job.outdir)
168168
if runtime_context.research_obj is not None:
169169
if not isinstance(process, Workflow):
170-
runtime_context.prov_obj = process.provenance_object
170+
prov_obj = process.provenance_object
171171
else:
172-
runtime_context.prov_obj = job.prov_obj
173-
assert runtime_context.prov_obj
174-
runtime_context.prov_obj.evaluate(
175-
process, job, job_order_object,
176-
runtime_context.research_obj)
177-
process_run_id =\
178-
runtime_context.prov_obj.record_process_start(
179-
process, job)
180-
runtime_context = runtime_context.copy()
172+
prov_obj = job.prov_obj
173+
if prov_obj:
174+
runtime_context.prov_obj = prov_obj
175+
prov_obj.evaluate(
176+
process, job, job_order_object,
177+
runtime_context.research_obj)
178+
process_run_id =\
179+
prov_obj.record_process_start(process, job)
180+
runtime_context = runtime_context.copy()
181181
runtime_context.process_run_id = process_run_id
182182
job.run(runtime_context)
183183
else:

0 commit comments

Comments
 (0)