|
8 | 8 | import sys
|
9 | 9 | from io import open
|
10 | 10 |
|
11 |
| -from typing import (Dict, List, Text, MutableMapping, Any) |
| 11 | +from typing import (Dict, List, Text, Optional, MutableMapping, Any) |
12 | 12 |
|
13 | 13 | from .errors import WorkflowException
|
14 | 14 | from .job import ContainerCommandLineJob
|
|
21 | 21 |
|
22 | 22 | class SingularityCommandLineJob(ContainerCommandLineJob):
|
23 | 23 | @staticmethod
|
24 |
| - def get_image(dockerRequirement, pull_image, dry_run=False): |
25 |
| - # type: (Dict[Text, Text], bool, bool) -> bool |
| 24 | + def get_image(dockerRequirement, # type: Dict[Text, Text] |
| 25 | + pull_image, # type: bool |
| 26 | + dry_run=False # type: bool |
| 27 | + ): |
| 28 | + # type: (...) -> bool |
| 29 | + """ |
| 30 | + Acquire the software container image in the specified dockerRequirement |
| 31 | + using Singularity and returns the success as a bool. Updates the |
| 32 | + provided dockerRequirement with the specific dockerImageId to the full |
| 33 | + path of the local image, if found. Likewise the |
| 34 | + dockerRequirement['dockerPull'] is updated to a docker:// URI if needed. |
| 35 | + """ |
26 | 36 | found = False
|
27 | 37 |
|
28 | 38 | if "dockerImageId" not in dockerRequirement and "dockerPull" in dockerRequirement:
|
@@ -77,12 +87,22 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
|
77 | 87 |
|
78 | 88 | return found
|
79 | 89 |
|
80 |
| - def get_from_requirements(self, r, req, pull_image, dry_run=False, force_pull=False): |
81 |
| - # type: (Dict[Text, Text], bool, bool, bool, bool) -> Text |
82 |
| - # returns the filename of the Singularity image (e.g. hello-world-latest.img) |
| 90 | + def get_from_requirements(self, |
| 91 | + r, # type: Optional[Dict[Text, Text]] |
| 92 | + req, # type: bool |
| 93 | + pull_image, # type: bool |
| 94 | + dry_run=False, # type: bool |
| 95 | + force_pull=False # type: bool |
| 96 | + ): |
| 97 | + # type: (...) -> Text |
| 98 | + """ |
| 99 | + Returns the filename of the Singularity image (e.g. |
| 100 | + hello-world-latest.img). |
| 101 | + """ |
83 | 102 |
|
84 | 103 | if force_pull:
|
85 |
| - _logger.warn("--force-docker-pull currently not supported for singularity") |
| 104 | + _logger.warning("--force-docker-pull currently not supported for " |
| 105 | + "singularity") |
86 | 106 |
|
87 | 107 | if r:
|
88 | 108 | errmsg = None
|
@@ -160,12 +180,19 @@ def add_volumes(self, pathmapper, runtime, stage_output):
|
160 | 180 | docker_windows_path_adjust(createtmp),
|
161 | 181 | docker_windows_path_adjust(vol.target)))
|
162 | 182 |
|
163 |
| - def create_runtime(self, env, rm_container=True, record_container_id=False, cidfile_dir="", |
164 |
| - cidfile_prefix="", **kwargs): |
165 |
| - # type: (MutableMapping[Text, Text], bool, bool, Text, Text, **Any) -> List |
| 183 | + def create_runtime(self, |
| 184 | + env, # type: MutableMapping[Text, Text] |
| 185 | + rm_container=True, # type: bool |
| 186 | + record_container_id=False, # type: bool |
| 187 | + cidfile_dir="", # type: Text |
| 188 | + cidfile_prefix="", # type: Text |
| 189 | + **kwargs |
| 190 | + ): |
| 191 | + # type: (...) -> List |
| 192 | + """ Returns the Singularity runtime list of commands and options.""" |
166 | 193 |
|
167 | 194 | runtime = [u"singularity", u"--quiet", u"exec", u"--contain", u"--pid",
|
168 |
| - u"--ipc"] # , u"--userns"] |
| 195 | + u"--ipc"] # , u"--userns"] |
169 | 196 | runtime.append(u"--bind")
|
170 | 197 | runtime.append(u"{}:{}:rw".format(
|
171 | 198 | docker_windows_path_adjust(os.path.realpath(self.outdir)),
|
|
0 commit comments