Skip to content

Commit 353dbed

Browse files
authored
Merge pull request #617 from common-workflow-language/singularity-support
Singularity support
2 parents fcd80f9 + 10bef24 commit 353dbed

File tree

9 files changed

+506
-270
lines changed

9 files changed

+506
-270
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ MODULE=cwltool
2727
# `[[` conditional expressions.
2828
PYSOURCES=$(wildcard ${MODULE}/**.py tests/*.py) setup.py
2929
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pydocstyle flake8 pytest isort mock
30-
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount python-flake8 python-mock
30+
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount \
31+
python-flake8 python-mock shellcheck
3132
VERSION=1.0.$(shell date +%Y%m%d%H%M%S --date=`git log --first-parent \
3233
--max-count=1 --format=format:%cI`)
3334
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ or
139139
140140
cwltool --user-space-docker-cmd=dx-docker 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
141141
142+
``cwltool`` can use `Singularity <http://singularity.lbl.gov/>`_ as a Docker container runtime, an experimental feature.
143+
Singularity will run software containers specified in ``DockerRequirement`` and therefore works with Docker images only,
144+
native Singularity images are not supported.
145+
To use Singularity as the Docker container runtime, provide ``--singularity`` command line option to ``cwltool``.
146+
147+
148+
.. code:: bash
149+
150+
cwltool --singularity https://raw.githubusercontent.com/common-workflow-language/common-workflow-language/master/v1.0/v1.0/v1.0/cat3-tool-mediumcut.cwl https://github.com/common-workflow-language/common-workflow-language/blob/master/v1.0/v1.0/cat-job.json
151+
142152
Tool or workflow loading from remote or local locations
143153
-------------------------------------------------------
144154

cwltool/argparser.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,25 @@
1919

2020

2121
def arg_parser(): # type: () -> argparse.ArgumentParser
22-
parser = argparse.ArgumentParser(description='Reference executor for Common Workflow Language')
22+
parser = argparse.ArgumentParser(
23+
description='Reference executor for Common Workflow Language standards.')
2324
parser.add_argument("--basedir", type=Text)
2425
parser.add_argument("--outdir", type=Text, default=os.path.abspath('.'),
2526
help="Output directory, default current directory")
2627

27-
parser.add_argument("--no-container", action="store_false", default=True,
28-
help="Do not execute jobs in a Docker container, even when specified by the CommandLineTool",
29-
dest="use_container")
3028
parser.add_argument("--parallel", action="store_true", default=False,
3129
help="[experimental] Run jobs in parallel. "
3230
"Does not currently keep track of ResourceRequirements like the number of cores"
3331
"or memory and can overload this system")
34-
parser.add_argument("--preserve-environment", type=Text, action="append",
35-
help="Preserve specific environment variable when running CommandLineTools. May be provided multiple times.",
36-
metavar="ENVVAR",
37-
default=["PATH"],
32+
envgroup = parser.add_mutually_exclusive_group()
33+
envgroup.add_argument("--preserve-environment", type=Text, action="append",
34+
help="Preserve specific environment variable when "
35+
"running CommandLineTools. May be provided multiple "
36+
"times.", metavar="ENVVAR", default=["PATH"],
3837
dest="preserve_environment")
39-
40-
parser.add_argument("--preserve-entire-environment", action="store_true",
41-
help="Preserve entire parent environment when running CommandLineTools.",
42-
default=False,
38+
envgroup.add_argument("--preserve-entire-environment", action="store_true",
39+
help="Preserve all environment variable when running "
40+
"CommandLineTools.", default=False,
4341
dest="preserve_entire_environment")
4442

4543
exgroup = parser.add_mutually_exclusive_group()
@@ -154,10 +152,22 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
154152
"timestamps to the errors, warnings, and "
155153
"notifications.")
156154
parser.add_argument("--js-console", action="store_true", help="Enable javascript console output")
157-
parser.add_argument("--user-space-docker-cmd",
155+
dockergroup = parser.add_mutually_exclusive_group()
156+
dockergroup.add_argument("--user-space-docker-cmd", metavar="CMD",
158157
help="(Linux/OS X only) Specify a user space docker "
159158
"command (like udocker or dx-docker) that will be "
160159
"used to call 'pull' and 'run'")
160+
dockergroup.add_argument("--singularity", action="store_true",
161+
default=False, help="[experimental] Use "
162+
"Singularity runtime for running containers. "
163+
"Requires Singularity v2.3.2+ and Linux with kernel "
164+
"version v3.18+ or with overlayfs support "
165+
"backported.")
166+
dockergroup.add_argument("--no-container", action="store_false",
167+
default=True, help="Do not execute jobs in a "
168+
"Docker container, even when `DockerRequirement` "
169+
"is specified under `hints`.",
170+
dest="use_container")
161171

162172
dependency_resolvers_configuration_help = argparse.SUPPRESS
163173
dependencies_directory_help = argparse.SUPPRESS
@@ -237,8 +247,15 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
237247
parser.add_argument("--overrides", type=str,
238248
default=None, help="Read process requirement overrides from file.")
239249

240-
parser.add_argument("workflow", type=Text, nargs="?", default=None)
241-
parser.add_argument("job_order", nargs=argparse.REMAINDER)
250+
parser.add_argument("workflow", type=Text, nargs="?", default=None,
251+
metavar='cwl_document', help="path or URL to a CWL Workflow, "
252+
"CommandLineTool, or ExpressionTool. If the `inputs_object` has a "
253+
"`cwl:tool` field indicating the path or URL to the cwl_document, "
254+
" then the `workflow` argument is optional.")
255+
parser.add_argument("job_order", nargs=argparse.REMAINDER,
256+
metavar='inputs_object', help="path or URL to a YAML or JSON "
257+
"formatted description of the required input values for the given "
258+
"`cwl_document`.")
242259

243260
return parser
244261

cwltool/command_line_tool.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@
2121
from six.moves import urllib
2222

2323
from .builder import CONTENT_LIMIT, Builder, substitute
24+
from .docker import DockerCommandLineJob
2425
from .errors import WorkflowException
2526
from .flatten import flatten
26-
from .job import CommandLineJob, DockerCommandLineJob, JobBase
27+
from .job import CommandLineJob, JobBase
2728
from .pathmapper import (PathMapper, adjustDirObjs, adjustFileObjs,
2829
get_listing, trim_listing, visit_class)
2930
from .process import (Process, UnsupportedRequirement,
3031
_logger_validation_warnings, compute_checksums,
3132
normalizeFilesDirs, shortname, uniquename)
33+
from .singularity import SingularityCommandLineJob
3234
from .stdfsaccess import StdFsAccess
3335
from .utils import aslist, docker_windows_path_adjust, convert_pathsep_to_unix, windows_default_container_id, onWindows
3436
from six.moves import map
@@ -213,7 +215,10 @@ def makeJobRunner(self, use_container=True, **kwargs): # type: (Optional[bool],
213215
_logger.warning(DEFAULT_CONTAINER_MSG % (windows_default_container_id, windows_default_container_id))
214216

215217
if dockerReq and use_container:
216-
return DockerCommandLineJob()
218+
if kwargs.get('singularity'):
219+
return SingularityCommandLineJob()
220+
else:
221+
return DockerCommandLineJob()
217222
else:
218223
for t in reversed(self.requirements):
219224
if t["class"] == "DockerRequirement":

0 commit comments

Comments
 (0)