Skip to content

Commit 047863d

Browse files
author
Anton Khodak
committed
Not require docker if runtime is singularity
1 parent 01c02c1 commit 047863d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

cwltool/job.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import shellescape
1919

20+
from cwltool import singularity
2021
from .utils import copytree_with_merge, docker_windows_path_adjust, onWindows
2122
from . import docker
2223
from .builder import Builder
@@ -425,8 +426,12 @@ def run(self, pull_image=True, rm_container=True,
425426
try:
426427
env = cast(MutableMapping[Text, Text], os.environ)
427428
if docker_req and kwargs.get("use_container"):
428-
img_id = str(docker.get_from_requirements(
429-
docker_req, True, pull_image))
429+
if container_manager == "docker":
430+
img_id = str(docker.get_from_requirements(
431+
docker_req, True, pull_image))
432+
elif container_manager == "singularity":
433+
img_id = str(singularity.get_from_requirements(
434+
docker_req, True, pull_image))
430435
if img_id is None:
431436
if self.builder.find_default_container:
432437
default_container = self.builder.find_default_container()
@@ -437,16 +442,17 @@ def run(self, pull_image=True, rm_container=True,
437442
if docker_req and img_id is None and kwargs.get("use_container"):
438443
raise Exception("Docker image not available")
439444
except Exception as e:
440-
_logger.debug("Docker error", exc_info=True)
445+
container = container_manager.capitalize()
446+
_logger.debug("%s error" % container, exc_info=True)
441447
if docker_is_req:
442448
raise UnsupportedRequirement(
443-
"Docker is required to run this tool: %s" % e)
449+
"%s is required to run this tool: %s" % (container, e))
444450
else:
445451
raise WorkflowException(
446-
"Docker is not available for this tool, try "
447-
"--no-container to disable Docker, or install "
452+
"{0} is not available for this tool, try "
453+
"--no-container to disable {0}, or install "
448454
"a user space Docker replacement like uDocker with "
449-
"--user-space-docker-cmd.: %s" % e)
455+
"--user-space-docker-cmd.: {1}".format(container, e))
450456

451457
self._setup(kwargs)
452458

@@ -506,7 +512,6 @@ def run(self, pull_image=True, rm_container=True,
506512

507513
for t, v in self.environment.items():
508514
runtime.append(u"--env=%s=%s" % (t, v))
509-
runtime.append(img_id)
510515

511516
elif container_manager == "singularity":
512517
runtime = [u"singularity", u"--quiet", u"exec"]
@@ -535,7 +540,7 @@ def run(self, pull_image=True, rm_container=True,
535540
for t, v in self.environment.items():
536541
env["SINGULARITYENV_" + t] = v
537542

538-
runtime.append("docker://" + img_id)
543+
runtime.append(img_id)
539544

540545
self._execute(
541546
runtime, env, rm_tmpdir=rm_tmpdir, move_outputs=move_outputs)

0 commit comments

Comments
 (0)