Skip to content

Commit 1a04179

Browse files
author
Peter Amstutz
authored
Merge branch 'master' into argparser-require
2 parents 01dcc73 + ecdfe1e commit 1a04179

File tree

9 files changed

+63
-44
lines changed

9 files changed

+63
-44
lines changed

.travis.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@ install:
2020
- pip install tox-travis
2121
jobs:
2222
include:
23-
- stage: test
24-
python: "2.7"
25-
- stage: test
26-
python: "3.5"
27-
- stage: test
28-
python: "3.6"
29-
- stage: test
30-
python: "3.7"
31-
#- stage: test
32-
# python: "3.8-dev" # ruamel.yaml doesn't support 3.8 yet
33-
- stage: release-test
34-
python: "2.7"
23+
- python: "2.7"
24+
- python: "3.5"
25+
- python: "3.6"
26+
- python: "3.7"
27+
#- python: "3.8-dev" # ruamel.yaml doesn't support 3.8 yet
28+
- python: "3.7"
3529
script: RELEASE_SKIP=head ${TRAVIS_BUILD_DIR}/release-test.sh
3630
script: tox
3731
branches:

Makefile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ VERSION=1.0.$(shell TZ=UTC git log --first-parent --max-count=1 \
3434
--format=format:%cd --date=format-local:%Y%m%d%H%M%S)
3535
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
3636
UNAME_S=$(shell uname -s)
37-
ifeq ($(UNAME_S),Linux)
38-
nproc=$(shell nproc)
39-
endif
40-
ifeq ($(UNAME_S),Darwin)
41-
nproc=$(shell sysctl -n hw.physicalcpu)
42-
endif
4337

4438
## all : default task
4539
all:
@@ -120,11 +114,11 @@ format: autopep8
120114
## pylint : run static code analysis on Python code
121115
pylint: $(PYSOURCES)
122116
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
123-
$^ -j$(nproc)|| true
117+
$^ -j0|| true
124118

125119
pylint_report.txt: ${PYSOURCES}
126120
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
127-
$^ -j$(nproc)> $@ || true
121+
$^ -j0> $@ || true
128122

129123
diff_pylint_report: pylint_report.txt
130124
diff-quality --violations=pylint pylint_report.txt
@@ -154,11 +148,11 @@ diff-cover.html: coverage.xml
154148

155149
## test : run the ${MODULE} test suite
156150
test: $(pysources)
157-
python setup.py test --addopts "-n$(nproc) --dist=loadfile"
151+
python setup.py test --addopts "-n auto --dist=loadfile"
158152

159153
## testcov : run the ${MODULE} test suite and collect coverage
160154
testcov: $(pysources)
161-
python setup.py test --addopts "--cov cwltool -n$(nproc) --dist=loadfile"
155+
python setup.py test --addopts "--cov cwltool -n auto --dist=loadfile"
162156

163157
sloccount.sc: ${PYSOURCES} Makefile
164158
sloccount --duplicates --wide --details $^ > $@

cwltool/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def generate_arg(self, binding): # type: (Dict[Text, Any]) -> List[Text]
426426
if sep:
427427
args.extend([prefix, self.tostr(j)])
428428
else:
429-
args.append("" if not prefix else prefix + self.tostr(j))
429+
args.append(self.tostr(j) if prefix is None else prefix + self.tostr(j))
430430

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

cwltool/job.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,16 @@ def run(self,
621621
img_id = str(docker_req["dockerImageId"])
622622
elif 'dockerPull' in docker_req:
623623
img_id = str(docker_req["dockerPull"])
624+
cmd = [user_space_docker_cmd, "pull", img_id]
625+
_logger.info(Text(cmd))
626+
try:
627+
subprocess.check_call(cmd, stdout=sys.stderr)
628+
except OSError:
629+
raise WorkflowException(SourceLine(docker_req).makeError(
630+
"Either Docker container {} is not available with "
631+
"user space docker implementation {} or {} is missing "
632+
"or broken.".format(img_id, user_space_docker_cmd,
633+
user_space_docker_cmd)))
624634
else:
625635
raise WorkflowException(SourceLine(docker_req).makeError(
626636
"Docker image must be specified as 'dockerImageId' or "

cwltool/update.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from typing import (Any, Callable, Dict, List, MutableMapping, MutableSequence,
66
Optional, Tuple, Union)
77

8+
from functools import partial
9+
810
from ruamel.yaml.comments import CommentedMap, CommentedSeq
911
from schema_salad import validate
1012
from schema_salad.ref_resolver import Loader # pylint: disable=unused-import
@@ -61,8 +63,8 @@ def rewrite_requirements(t): # type: (MutableMapping[Text, Union[Text, Dict[Tex
6163
type(s), s))
6264

6365

64-
def update_secondaryFiles(t):
65-
# type: (Any) -> Union[MutableSequence[MutableMapping[Text, Text]], MutableMapping[Text, Text]]
66+
def update_secondaryFiles(t, top=False):
67+
# type: (Any, bool) -> Union[MutableSequence[MutableMapping[Text, Text]], MutableMapping[Text, Text]]
6668
if isinstance(t, CommentedSeq):
6769
new_seq = copy.deepcopy(t)
6870
for index, entry in enumerate(t):
@@ -72,6 +74,8 @@ def update_secondaryFiles(t):
7274
return CommentedSeq([update_secondaryFiles(p) for p in t])
7375
elif isinstance(t, MutableMapping):
7476
return t
77+
elif top:
78+
return CommentedSeq([CommentedMap([("pattern", t)])])
7579
else:
7680
return CommentedMap([("pattern", t)])
7781

@@ -88,7 +92,7 @@ def fix_inputBinding(t): # type: (Dict[Text, Any]) -> None
8892

8993
visit_class(doc, ("CommandLineTool","Workflow"), rewrite_requirements)
9094
visit_class(doc, ("ExpressionTool","Workflow"), fix_inputBinding)
91-
visit_field(doc, "secondaryFiles", update_secondaryFiles)
95+
visit_field(doc, "secondaryFiles", partial(update_secondaryFiles, top=True))
9296

9397
upd = doc
9498
if isinstance(upd, MutableMapping) and "$graph" in upd:

release-test.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,13 @@ package=cwltool
99
module=cwltool
1010
slug=${TRAVIS_PULL_REQUEST_SLUG:=common-workflow-language/cwltool}
1111
repo=https://github.com/${slug}.git
12-
parallel=""
13-
if [[ "${OSTYPE}" == linux* ]]
14-
then
15-
parallel=-n$(( $(nproc) / 2 ))
16-
fi
17-
if [[ "${OSTYPE}" == darwin* ]]
18-
then
19-
parallel=-n$(( $(sysctl -n hw.physicalcpu) / 2 ))
20-
fi
2112
test_prefix=""
2213
run_tests() {
2314
local mod_loc
2415
mod_loc=$(pip show ${package} |
2516
grep ^Location | awk '{print $2}')/${module}
2617
${test_prefix}bin/py.test "--ignore=${mod_loc}/schemas/" \
27-
--pyarg -x ${module} ${parallel} --dist=loadfile
18+
--pyarg -x ${module} -n auto --dist=loadfile
2819
}
2920
pipver=7.0.2 # minimum required version of pip
3021
setuptoolsver=24.2.0 # required to generate correct metadata for
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class: CommandLineTool
2+
cwlVersion: v1.0
3+
baseCommand: []
4+
inputs:
5+
echo: boolean
6+
outputs: []
7+
arguments:
8+
- position: 1
9+
shellQuote: false
10+
prefix: ''
11+
valueFrom: "non_existing_app"
12+
- position: 0
13+
prefix: ''
14+
separate: false
15+
shellQuote: false
16+
valueFrom: "echo"
17+
requirements:
18+
- class: ShellCommandRequirement

tests/test_examples.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ def test_bad_userspace_runtime(factor):
954954
"--user-space-docker-cmd=quaquioN", "--default-container=debian",
955955
get_data(test_file), get_data(job_file)])
956956
error_code, stdout, stderr = get_main_output(commands)
957-
assert "'quaquioN' not found:" in stderr, stderr
957+
assert "or quaquioN is missing or broken" in stderr, stderr
958958
assert error_code == 1
959959

960960
@windows_needs_docker
@@ -1018,3 +1018,11 @@ def test_env_filtering(factor):
10181018
else:
10191019
target = 4
10201020
assert json.loads(stdout)['env_count'] == target, (error_code, stdout, stderr)
1021+
1022+
@windows_needs_docker
1023+
def test_v1_0_arg_empty_prefix_separate_false():
1024+
test_file = "tests/arg-empty-prefix-separate-false.cwl"
1025+
error_code, stdout, stderr = get_main_output(
1026+
['--debug', get_data(test_file), "--echo"])
1027+
assert "completed success" in stderr
1028+
assert error_code == 0

tests/test_udocker.py

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

1717
@classmethod
1818
def setup_class(cls):
19-
install_cmds = [
20-
"curl https://raw.githubusercontent.com/indigo-dc/udocker/master/udocker.py -o ./udocker",
21-
"chmod u+rx ./udocker",
22-
"./udocker install"]
23-
2419
test_cwd = os.getcwd()
2520
test_environ = os.environ.copy()
26-
2721
cls.docker_install_dir = tempfile.mkdtemp()
2822
os.chdir(cls.docker_install_dir)
2923

24+
url="https://download.ncg.ingrid.pt/webdav/udocker/udocker-1.1.3.tar.gz"
25+
install_cmds = [
26+
["curl", url, "-o", "./udocker-tarball.tgz"],
27+
["tar", "xzvf", "udocker-tarball.tgz", "udocker"],
28+
["bash", "-c", "UDOCKER_TARBALL={}/udocker-tarball.tgz ./udocker install".format(cls.docker_install_dir)]]
29+
3030
os.environ['UDOCKER_DIR'] = os.path.join(cls.docker_install_dir, ".udocker")
3131
os.environ['HOME'] = cls.docker_install_dir
3232

3333
results = []
3434
for _ in range(3):
35-
results = [subprocess.call(cmd.split()) for cmd in install_cmds]
35+
results = [subprocess.call(cmds) for cmds in install_cmds]
3636
if sum(results) == 0:
3737
break
3838
subprocess.call(["rm", "./udocker"])

0 commit comments

Comments
 (0)