diff --git a/cwltool/draft2tool.py b/cwltool/draft2tool.py index 64213d067..5a52836c2 100644 --- a/cwltool/draft2tool.py +++ b/cwltool/draft2tool.py @@ -21,7 +21,9 @@ from .errors import WorkflowException from .job import JobBase, CommandLineJob, DockerCommandLineJob from .pathmapper import PathMapper, get_listing, trim_listing -from .process import Process, shortname, uniquename, normalizeFilesDirs, compute_checksums, _logger_validation_warnings +from .process import (Process, shortname, uniquename, normalizeFilesDirs, + compute_checksums, _logger_validation_warnings, + UnsupportedRequirement) from .stdfsaccess import StdFsAccess from .utils import aslist @@ -177,6 +179,11 @@ def makeJobRunner(self, use_container=True): # type: (Optional[bool]) -> JobBas if dockerReq and use_container: return DockerCommandLineJob() else: + for t in reversed(self.requirements): + if t["class"] == "DockerRequirement": + raise UnsupportedRequirement( + "--no-container, but this CommandLineTool has " + "DockerRequirement under 'requirements'.") return CommandLineJob() def makePathMapper(self, reffiles, stagedir, **kwargs): diff --git a/cwltool/job.py b/cwltool/job.py index 8cc279508..918522be8 100644 --- a/cwltool/job.py +++ b/cwltool/job.py @@ -18,7 +18,8 @@ from .docker_uid import docker_vm_uid from .errors import WorkflowException from .pathmapper import PathMapper -from .process import get_feature, empty_subtree, stageFiles +from .process import (get_feature, empty_subtree, stageFiles, + UnsupportedRequirement) _logger = logging.getLogger("cwltool") @@ -335,9 +336,12 @@ def run(self, pull_image=True, rm_container=True, except Exception as e: _logger.debug("Docker error", exc_info=True) if docker_is_req: - raise WorkflowException("Docker is required to run this tool: %s" % e) + raise UnsupportedRequirement( + "Docker is required to run this tool: %s" % e) else: - raise WorkflowException("Docker is not available for this tool, try --no-container to disable Docker: %s" % e) + raise WorkflowException( + "Docker is not available for this tool, try --no-container" + " to disable Docker: %s" % e) self._setup() diff --git a/cwltool/process.py b/cwltool/process.py index 02c5684c1..4b0942e52 100644 --- a/cwltool/process.py +++ b/cwltool/process.py @@ -530,11 +530,6 @@ def _init_job(self, joborder, **kwargs): builder.mutation_manager = kwargs.get("mutation_manager") dockerReq, is_req = self.get_requirement("DockerRequirement") - - if dockerReq and is_req and not kwargs.get("use_container"): - raise WorkflowException( - "Document has DockerRequirement under 'requirements' but use_container is false. DockerRequirement must be under 'hints' or use_container must be true.") - builder.make_fs_access = kwargs.get("make_fs_access") or StdFsAccess builder.fs_access = builder.make_fs_access(kwargs["basedir"])