Skip to content

Commit c7dbb9f

Browse files
authored
Merge branch 'master' into bad_type_error
2 parents 7e7b91a + ac6fbc8 commit c7dbb9f

File tree

9 files changed

+51
-25
lines changed

9 files changed

+51
-25
lines changed

README.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ CWL conformance tests: |Conformance Status| |Linux Status| |Windows Status| |Cov
77

88
.. |Conformance Status| image:: https://ci.commonwl.org/buildStatus/icon?job=cwltool-conformance
99
:target: https://ci.commonwl.org/job/cwltool-conformance/
10-
10+
1111
.. |Linux Status| image:: https://img.shields.io/travis/common-workflow-language/cwltool/master.svg?label=Linux%20builds
1212
:target: https://travis-ci.org/common-workflow-language/cwltool
13-
13+
1414
.. |Windows Status| image:: https://img.shields.io/appveyor/ci/mr-c/cwltool/master.svg?label=Windows%20builds
1515
:target: https://ci.appveyor.com/project/mr-c/cwltool
1616

1717
.. |Coverage Status| image:: https://img.shields.io/codecov/c/github/common-workflow-language/cwltool.svg
1818
:target: https://codecov.io/gh/common-workflow-language/cwltool
19-
19+
2020
This is the reference implementation of the Common Workflow Language. It is
2121
intended to feature complete and provide comprehensive validation of CWL
2222
files as well as provide other tools related to working with CWL.
@@ -88,6 +88,8 @@ List of all environment can be seen using:
8888
``tox --listenvs``
8989
and running a specfic test env using:
9090
``tox -e <env name>``
91+
and additionally run a specific test using this format:
92+
``tox -e py36-unit -- tests/test_examples.py::TestParamMatching``
9193

9294
- Running the entire suite of CWL conformance tests:
9395

@@ -139,8 +141,8 @@ Run `cwltool` just as you normally would, but with the new option, e.g. from the
139141
.. code:: bash
140142
141143
cwltool --user-space-docker-cmd=udocker https://raw.githubusercontent.com/common-workflow-language/common-workflow-language/master/v1.0/v1.0/test-cwl-out2.cwl https://github.com/common-workflow-language/common-workflow-language/blob/master/v1.0/v1.0/empty.json
142-
143-
or
144+
145+
or
144146

145147
.. code:: bash
146148

cwltool/argparser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
214214
parser.add_argument("--custom-net", type=Text,
215215
help="Will be passed to `docker run` as the '--net' "
216216
"parameter. Implies '--enable-net'.")
217+
parser.add_argument("--disable-validate", dest="do_validate",
218+
action="store_false", default=True,
219+
help=argparse.SUPPRESS)
217220

218221
exgroup = parser.add_mutually_exclusive_group()
219222
exgroup.add_argument("--enable-ga4gh-tool-registry", action="store_true", help="Enable resolution using GA4GH tool registry API",

cwltool/docker.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
import datetime
1313
import requests
14-
from typing import (Dict, List, Text, Any, MutableMapping)
14+
from typing import (Dict, List, Text, Any, MutableMapping, Set)
15+
import threading
1516

1617
from .docker_id import docker_vm_id
1718
from .errors import WorkflowException
@@ -22,17 +23,23 @@
2223

2324
_logger = logging.getLogger("cwltool")
2425

26+
found_images = set() # type: Set[Text]
27+
found_images_lock = threading.Lock()
2528

2629
class DockerCommandLineJob(ContainerCommandLineJob):
2730

2831
@staticmethod
29-
def get_image(dockerRequirement, pull_image, dry_run=False):
30-
# type: (Dict[Text, Text], bool, bool) -> bool
32+
def get_image(dockerRequirement, pull_image, dry_run=False, force_pull=False):
33+
# type: (Dict[Text, Text], bool, bool, bool) -> bool
3134
found = False
3235

3336
if "dockerImageId" not in dockerRequirement and "dockerPull" in dockerRequirement:
3437
dockerRequirement["dockerImageId"] = dockerRequirement["dockerPull"]
3538

39+
with found_images_lock:
40+
if dockerRequirement["dockerImageId"] in found_images:
41+
return True
42+
3643
for ln in subprocess.check_output(
3744
["docker", "images", "--no-trunc", "--all"]).decode('utf-8').splitlines():
3845
try:
@@ -58,7 +65,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
5865
except ValueError:
5966
pass
6067

61-
if not found and pull_image:
68+
if (force_pull or not found) and pull_image:
6269
cmd = [] # type: List[Text]
6370
if "dockerPull" in dockerRequirement:
6471
cmd = ["docker", "pull", str(dockerRequirement["dockerPull"])]
@@ -106,10 +113,14 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
106113
subprocess.check_call(cmd, stdout=sys.stderr)
107114
found = True
108115

116+
if found:
117+
with found_images_lock:
118+
found_images.add(dockerRequirement["dockerImageId"])
119+
109120
return found
110121

111-
def get_from_requirements(self, r, req, pull_image, dry_run=False):
112-
# type: (Dict[Text, Text], bool, bool, bool) -> Text
122+
def get_from_requirements(self, r, req, pull_image, dry_run=False, force_pull=False):
123+
# type: (Dict[Text, Text], bool, bool, bool, bool) -> Text
113124
if r:
114125
errmsg = None
115126
try:
@@ -125,7 +136,7 @@ def get_from_requirements(self, r, req, pull_image, dry_run=False):
125136
else:
126137
return None
127138

128-
if self.get_image(r, pull_image, dry_run):
139+
if self.get_image(r, pull_image, dry_run, force_pull=force_pull):
129140
return r["dockerImageId"]
130141
else:
131142
if req:

cwltool/job.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ class ContainerCommandLineJob(JobBase):
337337
__metaclass__ = ABCMeta
338338

339339
@abstractmethod
340-
def get_from_requirements(self, r, req, pull_image, dry_run=False):
341-
# type: (Dict[Text, Text], bool, bool, bool) -> Text
340+
def get_from_requirements(self, r, req, pull_image, dry_run=False, force_pull=False):
341+
# type: (Dict[Text, Text], bool, bool, bool, bool) -> Text
342342
pass
343343

344344
@abstractmethod
@@ -373,7 +373,7 @@ def run(self, pull_image=True, rm_container=True,
373373
try:
374374
env = cast(MutableMapping[Text, Text], os.environ)
375375
if docker_req and kwargs.get("use_container"):
376-
img_id = str(self.get_from_requirements(docker_req, True, pull_image))
376+
img_id = str(self.get_from_requirements(docker_req, True, pull_image, force_pull=kwargs.get("force_docker_pull")))
377377
if img_id is None:
378378
if self.builder.find_default_container:
379379
default_container = self.builder.find_default_container()

cwltool/load_tool.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def validate_document(document_loader, # type: Loader
193193
fetcher_constructor=None, # type: FetcherConstructorType
194194
skip_schemas=None, # type: bool
195195
overrides=None, # type: List[Dict]
196-
metadata=None # type: Optional[Dict]
196+
metadata=None, # type: Optional[Dict]
197+
do_validate=True
197198
):
198199
# type: (...) -> Tuple[Loader, Names, Union[Dict[Text, Any], List[Dict[Text, Any]]], Dict[Text, Any], Text]
199200
"""Validate a CWL document."""
@@ -209,7 +210,7 @@ def validate_document(document_loader, # type: Loader
209210
jobobj = None
210211
if "cwl:tool" in workflowobj:
211212
job_loader = default_loader(fetcher_constructor) # type: ignore
212-
jobobj, _ = job_loader.resolve_all(workflowobj, uri)
213+
jobobj, _ = job_loader.resolve_all(workflowobj, uri, checklinks=do_validate)
213214
uri = urllib.parse.urljoin(uri, workflowobj["https://w3id.org/cwl/cwl#tool"])
214215
del cast(dict, jobobj)["https://w3id.org/cwl/cwl#tool"]
215216

@@ -262,7 +263,7 @@ def validate_document(document_loader, # type: Loader
262263
_add_blank_ids(workflowobj)
263264

264265
workflowobj["id"] = fileuri
265-
processobj, new_metadata = document_loader.resolve_all(workflowobj, fileuri)
266+
processobj, new_metadata = document_loader.resolve_all(workflowobj, fileuri, checklinks=do_validate)
266267
if not isinstance(processobj, (CommentedMap, CommentedSeq)):
267268
raise ValidationException("Workflow must be a dict or list.")
268269

@@ -277,7 +278,8 @@ def validate_document(document_loader, # type: Loader
277278
if preprocess_only:
278279
return document_loader, avsc_names, processobj, new_metadata, uri
279280

280-
schema.validate_doc(avsc_names, processobj, document_loader, strict)
281+
if do_validate:
282+
schema.validate_doc(avsc_names, processobj, document_loader, strict)
281283

282284
if new_metadata.get("cwlVersion") != update.LATEST:
283285
processobj = cast(CommentedMap, cmap(update.update(

cwltool/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ def main(argsl=None, # type: List[str]
396396
'ga4gh_tool_registries': [],
397397
'find_default_container': None,
398398
'make_template': False,
399-
'overrides': None
399+
'overrides': None,
400+
'do_validate': True
400401
}):
401402
if not hasattr(args, k):
402403
setattr(args, k, v)
@@ -478,7 +479,8 @@ def main(argsl=None, # type: List[str]
478479
preprocess_only=args.print_pre or args.pack,
479480
fetcher_constructor=fetcher_constructor,
480481
skip_schemas=args.skip_schemas,
481-
overrides=overrides)
482+
overrides=overrides,
483+
do_validate=args.do_validate)
482484

483485
if args.print_pre:
484486
stdout.write(json.dumps(processobj, indent=4))
@@ -498,6 +500,7 @@ def main(argsl=None, # type: List[str]
498500

499501
make_tool_kwds["find_default_container"] = functools.partial(find_default_container, args)
500502
make_tool_kwds["overrides"] = overrides
503+
make_tool_kwds["disable_js_validation"] = args.disable_js_validation or (not args.do_validate)
501504

502505
tool = make_tool(document_loader, avsc_names, metadata, uri,
503506
makeTool, make_tool_kwds)

cwltool/singularity.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
6969

7070
return found
7171

72-
def get_from_requirements(self, r, req, pull_image, dry_run=False):
73-
# type: (Dict[Text, Text], bool, bool, bool) -> Text
72+
def get_from_requirements(self, r, req, pull_image, dry_run=False, force_pull=False):
73+
# type: (Dict[Text, Text], bool, bool, bool, bool) -> Text
7474
# returns the filename of the Singularity image (e.g. hello-world-latest.img)
75+
76+
if force_pull:
77+
_logger.warn("--force-docker-pull currently not supported for singularity")
78+
7579
if r:
7680
errmsg = None
7781
try:

cwltool/workflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ def __init__(self, toolpath_object, **kwargs):
557557
step_inputs.extend(step.tool["inputs"])
558558
step_outputs.extend(step.tool["outputs"])
559559

560-
static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs)
560+
if kwargs.get("do_validate", True):
561+
static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs)
561562

562563

563564
def job(self,

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ deps =
2424
py{27,34,35,36}-lint: flake8
2525

2626
commands =
27-
py{27,34,35,36}-unit: python setup.py test --addopts "--cov-report xml --cov cwltool"
27+
py{27,34,35,36}-unit: python setup.py test --addopts "--cov-report xml --cov cwltool {posargs}"
2828
py{27,34,35,36}-unit: codecov
2929
py{27,34,35,36}-lint: flake8 schema_salad setup.py
3030

0 commit comments

Comments
 (0)