Skip to content

Commit 0eb42ff

Browse files
authored
Merge pull request #399 from common-workflow-language/better-error-no-docker
Better error no docker
2 parents 13084e4 + e868b16 commit 0eb42ff

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

cwltool/draft2tool.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
from .errors import WorkflowException
2222
from .job import JobBase, CommandLineJob, DockerCommandLineJob
2323
from .pathmapper import PathMapper, get_listing, trim_listing
24-
from .process import Process, shortname, uniquename, normalizeFilesDirs, compute_checksums, _logger_validation_warnings
24+
from .process import (Process, shortname, uniquename, normalizeFilesDirs,
25+
compute_checksums, _logger_validation_warnings,
26+
UnsupportedRequirement)
2527
from .stdfsaccess import StdFsAccess
2628
from .utils import aslist
2729

@@ -177,6 +179,11 @@ def makeJobRunner(self, use_container=True): # type: (Optional[bool]) -> JobBas
177179
if dockerReq and use_container:
178180
return DockerCommandLineJob()
179181
else:
182+
for t in reversed(self.requirements):
183+
if t["class"] == "DockerRequirement":
184+
raise UnsupportedRequirement(
185+
"--no-container, but this CommandLineTool has "
186+
"DockerRequirement under 'requirements'.")
180187
return CommandLineJob()
181188

182189
def makePathMapper(self, reffiles, stagedir, **kwargs):

cwltool/job.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from .docker_uid import docker_vm_uid
1919
from .errors import WorkflowException
2020
from .pathmapper import PathMapper
21-
from .process import get_feature, empty_subtree, stageFiles
21+
from .process import (get_feature, empty_subtree, stageFiles,
22+
UnsupportedRequirement)
2223

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

@@ -335,9 +336,12 @@ def run(self, pull_image=True, rm_container=True,
335336
except Exception as e:
336337
_logger.debug("Docker error", exc_info=True)
337338
if docker_is_req:
338-
raise WorkflowException("Docker is required to run this tool: %s" % e)
339+
raise UnsupportedRequirement(
340+
"Docker is required to run this tool: %s" % e)
339341
else:
340-
raise WorkflowException("Docker is not available for this tool, try --no-container to disable Docker: %s" % e)
342+
raise WorkflowException(
343+
"Docker is not available for this tool, try --no-container"
344+
" to disable Docker: %s" % e)
341345

342346
self._setup()
343347

cwltool/process.py

-5
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,6 @@ def _init_job(self, joborder, **kwargs):
530530
builder.mutation_manager = kwargs.get("mutation_manager")
531531

532532
dockerReq, is_req = self.get_requirement("DockerRequirement")
533-
534-
if dockerReq and is_req and not kwargs.get("use_container"):
535-
raise WorkflowException(
536-
"Document has DockerRequirement under 'requirements' but use_container is false. DockerRequirement must be under 'hints' or use_container must be true.")
537-
538533
builder.make_fs_access = kwargs.get("make_fs_access") or StdFsAccess
539534
builder.fs_access = builder.make_fs_access(kwargs["basedir"])
540535

0 commit comments

Comments
 (0)