Skip to content

Commit 7dec97b

Browse files
authored
restore udocker (#1293)
Fixes #1292
1 parent 7bfe73a commit 7dec97b

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

cwltool/argparser.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,17 @@ def arg_parser() -> argparse.ArgumentParser:
395395
dockergroup.add_argument(
396396
"--user-space-docker-cmd",
397397
metavar="CMD",
398-
help="(Linux/OS X only) Specify a user space docker "
399-
"command (like udocker or dx-docker) that will be "
400-
"used to call 'pull' and 'run'",
398+
help="(Linux/OS X only) Specify the path to udocker. Implies --udocker",
401399
)
400+
dockergroup.add_argument(
401+
"--udocker",
402+
help="(Linux/OS X only) Use the udocker runtime for running containers "
403+
"(equivalent to --user-space-docker-cmd=udocker).",
404+
action="store_const",
405+
const="udocker",
406+
dest="user_space_docker_cmd",
407+
)
408+
402409
dockergroup.add_argument(
403410
"--singularity",
404411
action="store_true",

cwltool/command_line_tool.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
)
6464
from .singularity import SingularityCommandLineJob
6565
from .stdfsaccess import StdFsAccess
66+
from .udocker import UDockerCommandLineJob
6667
from .utils import (
6768
aslist,
6869
convert_pathsep_to_unix,
@@ -357,6 +358,8 @@ def make_job_runner(self, runtimeContext: RuntimeContext) -> Type[JobBase]:
357358
if dockerReq is not None and runtimeContext.use_container:
358359
if runtimeContext.singularity:
359360
return SingularityCommandLineJob
361+
elif runtimeContext.user_space_docker_cmd:
362+
return UDockerCommandLineJob
360363
return DockerCommandLineJob
361364
for t in reversed(self.requirements):
362365
if t["class"] == "DockerRequirement":

cwltool/udocker.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Enables Docker software containers via the udocker runtime."""
2+
3+
from typing import List
4+
5+
from .docker import DockerCommandLineJob
6+
7+
8+
class UDockerCommandLineJob(DockerCommandLineJob):
9+
"""Runs a CommandLineJob in a sofware container using the udocker engine."""
10+
11+
@staticmethod
12+
def append_volume(
13+
runtime: List[str], source: str, target: str, writable: bool = False
14+
) -> None:
15+
"""Add binding arguments to the runtime list."""
16+
runtime.append(
17+
"--volume={}:{}:{}".format(source, target, "rw" if writable else "ro")
18+
)

tests/test_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ def test_no_compute_chcksum(tmpdir, factor):
10571057
assert "checksum" not in stdout
10581058

10591059

1060+
@pytest.mark.skipif(onWindows(), reason="udocker is Linux/macOS only")
10601061
@pytest.mark.parametrize("factor", test_factors)
10611062
def test_bad_userspace_runtime(factor):
10621063
test_file = "tests/wf/wc-tool.cwl"

tests/test_udocker.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
LINUX = sys.platform in ("linux", "linux2")
1313

1414

15-
# @pytest.mark.skipif(not LINUX, reason="LINUX only")
16-
@pytest.mark.skip(
17-
"Udocker install is broken, see https://github.com/indigo-dc/udocker/issues/221"
18-
)
15+
@pytest.mark.skipif(not LINUX, reason="LINUX only")
1916
class TestUdocker:
2017
udocker_path = None
2118

0 commit comments

Comments
 (0)