Skip to content

Commit 9eab54b

Browse files
author
Dennis Kennetz
committed
Merge branch 'singularity23_fix' of https://github.com/drkennetz/cwltool-singularity23-fix into singularity23_fix
necessary to perform a PR
2 parents a0fb578 + ae7e92b commit 9eab54b

File tree

129 files changed

+534
-13264
lines changed

Some content is hidden

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

129 files changed

+534
-13264
lines changed

.travis.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
dist: trusty
2-
sudo: required
1+
dist: xenial
32
services:
43
- docker
54

@@ -23,22 +22,20 @@ jobs:
2322
include:
2423
- stage: test
2524
python: "2.7"
26-
- stage: test
27-
python: "3.4"
2825
- stage: test
2926
python: "3.5"
3027
- stage: test
3128
python: "3.6"
3229
- stage: test
3330
python: "3.7"
34-
dist: xenial
31+
#- stage: test
32+
# python: "3.8-dev" # ruamel.yaml doesn't support 3.8 yet
3533
- stage: release-test
3634
python: "2.7"
3735
script: RELEASE_SKIP=head ${TRAVIS_BUILD_DIR}/release-test.sh
3836
script: tox
3937
branches:
4038
only:
4139
- master
42-
- singularity23_fix
4340
notifications:
4441
email: false

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Style guide:
22
PEP-8
3-
Python 2.7 + Python 3.4+ compatible code
3+
Python 2.7 + Python 3.5+ compatible code
44
PEP-484 type hints, in comments for Python 2.7 compatability
55
Vertically align the type hints in function definitions
66

77
In order to contribute to the development of ``cwltool``, you need to install cwltool from source (preferably in a virtual environment):
8-
Here's a rough
8+
Here's a rough guide (improvements are welcome!)
99
- Install virtualenv via pip: ``pip install virtualenv``
1010
- Clone the cwltool: ``git clone https://github.com/common-workflow-language/cwltool.git``
1111
- Switch to cwltool directory: ``cd cwltool``

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ intended to be feature complete and provide comprehensive validation of CWL
2525
files as well as provide other tools related to working with CWL.
2626

2727
This is written and tested for
28-
`Python <https://www.python.org/>`_ ``2.7 and 3.x {x = 4, 5, 6, 7}``
28+
`Python <https://www.python.org/>`_ ``2.7 and 3.x {x = 5, 6, 7}``
2929

3030
The reference implementation consists of two packages. The ``cwltool`` package
3131
is the primary Python module containing the reference implementation in the
@@ -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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ environment:
1212
PYTHON_VERSION: "2.7.x"
1313
PYTHON_ARCH: "64"
1414

15-
- PYTHON: "C:\\Python34-x64"
16-
PYTHON_VERSION: "3.4.x"
17-
PYTHON_ARCH: "64"
18-
1915
- PYTHON: "C:\\Python35-x64"
2016
PYTHON_VERSION: "3.5.x"
2117
PYTHON_ARCH: "64"
@@ -32,12 +28,12 @@ install:
3228
- ps: 'Install-Product node 0.12 x64'
3329
- "set PATH=%PYTHON%\\Scripts;%PATH%"
3430
- "%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"
31+
- "%PYTHON%\\python.exe -m pip install -U codecov -rtest-requirements.txt pytest-xdist==1.27 "
3632
# Note the use of a `^` to escape the `>`
3733

3834
build_script:
3935
- "%PYTHON%\\python.exe -m pip install -rrequirements.txt"
40-
- "%PYTHON%\\python.exe -m pip install -e ."
36+
- "%PYTHON%\\python.exe -m pip install -e .[deps]"
4137

4238
test_script:
4339
- |

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/argparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
105105

106106
exgroup = parser.add_mutually_exclusive_group()
107107
exgroup.add_argument("--enable-pull", default=True, action="store_true",
108-
help="Try to pull Docker images", dest="enable_pull")
108+
help="Try to pull Docker images", dest="pull_image")
109109

110110
exgroup.add_argument("--disable-pull", default=True, action="store_false",
111-
help="Do not try to pull Docker images", dest="enable_pull")
111+
help="Do not try to pull Docker images", dest="pull_image")
112112

113113
parser.add_argument("--rdf-serializer",
114114
help="Output RDF serialization format used by --print-rdf (one of turtle (default), n3, nt, xml)",

cwltool/builder.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ def content_limit_respected_read(f): # type: (IO) -> Text
5050

5151

5252
def substitute(value, replace): # type: (Text, Text) -> Text
53-
if replace[0] == "^":
54-
return substitute(value[0:value.rindex('.')], replace[1:])
53+
if replace.startswith("^"):
54+
try:
55+
return substitute(value[0:value.rindex('.')], replace[1:])
56+
except ValueError:
57+
# No extension to remove
58+
return value + replace.lstrip("^")
5559
return value + replace
5660

5761
def formatSubclassOf(fmt, cls, ontology, visited):
@@ -207,13 +211,12 @@ def bind_input(self,
207211
value_from_expression = False
208212
if "inputBinding" in schema and isinstance(schema["inputBinding"], MutableMapping):
209213
binding = CommentedMap(schema["inputBinding"].items())
210-
assert binding is not None
211214

212215
bp = list(aslist(lead_pos))
213216
if "position" in binding:
214217
position = binding["position"]
215-
if isinstance(position, str): # no need to test the CWL Version
216-
# the schema for v1.0 only allow ints
218+
if isinstance(position, str): # no need to test the CWL Version
219+
# the schema for v1.0 only allow ints
217220
binding['position'] = self.do_eval(position, context=datum)
218221
bp.append(binding['position'])
219222
else:
@@ -238,7 +241,6 @@ def bind_input(self,
238241
avsc = self.names.get_name(t["name"], "")
239242
if not avsc:
240243
avsc = make_avsc_object(convert_to_dict(t), self.names)
241-
assert avsc is not None
242244
if validate.validate(avsc, datum):
243245
schema = copy.deepcopy(schema)
244246
schema["type"] = t
@@ -379,7 +381,6 @@ def tostr(self, value): # type: (Any) -> Text
379381
# docker_req is none only when there is no dockerRequirement
380382
# mentioned in hints and Requirement
381383
path = docker_windows_path_adjust(value["path"])
382-
assert path is not None
383384
return path
384385
return value["path"]
385386
else:
@@ -424,8 +425,7 @@ def generate_arg(self, binding): # type: (Dict[Text, Any]) -> List[Text]
424425
if sep:
425426
args.extend([prefix, self.tostr(j)])
426427
else:
427-
assert prefix is not None
428-
args.append(prefix + self.tostr(j))
428+
args.append("" if not prefix else prefix + self.tostr(j))
429429

430430
return [a for a in args if a is not None]
431431

cwltool/command_line_tool.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ def revmap_file(builder, outdir, f):
157157
if "basename" not in f:
158158
f["basename"] = os.path.basename(path)
159159

160-
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.")
161162
revmap_f = builder.pathmapper.reversemap(path)
162163

163164
if revmap_f and not builder.pathmapper.mapper(revmap_f[0]).type.startswith("Writable"):
@@ -204,7 +205,8 @@ def check_adjust(builder, file_o):
204205
doesn't reach everything in builder.bindings
205206
"""
206207

207-
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.")
208210
file_o["path"] = docker_windows_path_adjust(
209211
builder.pathmapper.mapper(file_o["location"])[1])
210212
dn, bn = os.path.split(file_o["path"])
@@ -300,7 +302,7 @@ def job(self,
300302
if runtimeContext.cachedir and enableReuse:
301303
cachecontext = runtimeContext.copy()
302304
cachecontext.outdir = "/out"
303-
cachecontext.tmpdir = "/tmp"
305+
cachecontext.tmpdir = "/tmp" # nosec
304306
cachecontext.stagedir = "/stage"
305307
cachebuilder = self._init_job(job_order, cachecontext)
306308
cachebuilder.pathmapper = PathMapper(cachebuilder.files,
@@ -354,7 +356,8 @@ def job(self,
354356

355357
keydictstr = json_dumps(keydict, separators=(',', ':'),
356358
sort_keys=True)
357-
cachekey = hashlib.md5(keydictstr.encode('utf-8')).hexdigest()
359+
cachekey = hashlib.md5( # nosec
360+
keydictstr.encode('utf-8')).hexdigest()
358361

359362
_logger.debug("[job %s] keydictstr is %s -> %s", jobname,
360363
keydictstr, cachekey)
@@ -477,24 +480,24 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
477480
if self.tool.get("stdin"):
478481
with SourceLine(self.tool, "stdin", validate.ValidationException, debug):
479482
j.stdin = builder.do_eval(self.tool["stdin"])
480-
assert j.stdin is not None
481-
reffiles.append({"class": "File", "path": j.stdin})
483+
if j.stdin:
484+
reffiles.append({"class": "File", "path": j.stdin})
482485

483486
if self.tool.get("stderr"):
484487
with SourceLine(self.tool, "stderr", validate.ValidationException, debug):
485488
j.stderr = builder.do_eval(self.tool["stderr"])
486-
assert j.stderr is not None
487-
if os.path.isabs(j.stderr) or ".." in j.stderr:
488-
raise validate.ValidationException(
489-
"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)
490493

491494
if self.tool.get("stdout"):
492495
with SourceLine(self.tool, "stdout", validate.ValidationException, debug):
493496
j.stdout = builder.do_eval(self.tool["stdout"])
494-
assert j.stdout is not None
495-
if os.path.isabs(j.stdout) or ".." in j.stdout or not j.stdout:
496-
raise validate.ValidationException(
497-
"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)
498501

499502
if debug:
500503
_logger.debug(u"[job %s] command line bindings is %s", j.name,
@@ -674,8 +677,8 @@ def collect_output(self,
674677
globpatterns.extend(aslist(gb))
675678

676679
for gb in globpatterns:
677-
if gb.startswith(outdir):
678-
gb = gb[len(outdir) + 1:]
680+
if gb.startswith(builder.outdir):
681+
gb = gb[len(builder.outdir) + 1:]
679682
elif gb == ".":
680683
gb = outdir
681684
elif gb.startswith("/"):
@@ -717,7 +720,7 @@ def collect_output(self,
717720
files["contents"] = content_limit_respected_read_bytes(f).decode("utf-8")
718721
if compute_checksum:
719722
with fs_access.open(rfile["location"], "rb") as f:
720-
checksum = hashlib.sha1()
723+
checksum = hashlib.sha1() # nosec
721724
contents = f.read(1024 * 1024)
722725
while contents != b"":
723726
checksum.update(contents)

0 commit comments

Comments
 (0)