|
27 | 27 | )
|
28 | 28 |
|
29 | 29 | from galaxy.tool_util.deps import docker_util
|
| 30 | +from galaxy.tool_util.deps import singularity_util |
30 | 31 | from galaxy.tool_util.deps.container_volumes import DockerVolume
|
31 | 32 | from galaxy.util.commands import argv_to_str
|
32 | 33 | from galaxy.util.yaml_util import ordered_dump
|
|
117 | 118 | "planemo_dest": {
|
118 | 119 | "runner": "planemo_runner",
|
119 | 120 | "require_container": False,
|
120 |
| - "docker_enabled": False, |
121 |
| - "docker_sudo": False, |
122 |
| - "docker_sudo_cmd": docker_util.DEFAULT_SUDO_COMMAND, |
123 |
| - "docker_cmd": docker_util.DEFAULT_DOCKER_COMMAND, |
124 |
| - "docker_volumes": "$defaults", |
125 | 121 | },
|
126 | 122 | "upload_dest": {"runner": "planemo_runner", "docker_enabled": False},
|
127 | 123 | },
|
@@ -325,11 +321,14 @@ def local_galaxy_config(ctx, runnables, for_tests=False, **kwds):
|
325 | 321 |
|
326 | 322 | # Duplicate block in docker variant above.
|
327 | 323 | if kwds.get("mulled_containers", False):
|
328 |
| - if not kwds.get("docker", False): |
329 |
| - if ctx.get_option_source("docker") != OptionSource.cli: |
| 324 | + if not (kwds.get("docker", False) or kwds.get("singularity", False)): |
| 325 | + if ( |
| 326 | + ctx.get_option_source("docker") != OptionSource.cli |
| 327 | + and ctx.get_option_source("singularity") != OptionSource.cli |
| 328 | + ): |
330 | 329 | kwds["docker"] = True
|
331 | 330 | else:
|
332 |
| - raise Exception("Specified no docker and mulled containers together.") |
| 331 | + raise Exception("Specified --no-docker/--no-singularity and mulled containers together.") |
333 | 332 | conda_default_options = ("conda_auto_init", "conda_auto_install")
|
334 | 333 | use_conda_options = ("dependency_resolution", "conda_use_local", "conda_prefix", "conda_exec")
|
335 | 334 | if not any(kwds.get(_) for _ in use_conda_options) and all(
|
@@ -709,7 +708,7 @@ class GalaxyConfig(GalaxyInterface, metaclass=abc.ABCMeta):
|
709 | 708 |
|
710 | 709 | This assumes more than an API connection is available - Planemo needs to be able to
|
711 | 710 | start and stop the Galaxy instance, recover logs, etc... There are currently two
|
712 |
| - implementations - a locally executed Galaxy and one running inside a Docker containe |
| 711 | + implementations - a locally executed Galaxy and one running inside a Docker container |
713 | 712 | """
|
714 | 713 |
|
715 | 714 | @abc.abstractproperty
|
@@ -1322,26 +1321,43 @@ def _handle_job_config_file(
|
1322 | 1321 | "job_conf.yml",
|
1323 | 1322 | )
|
1324 | 1323 | planemo_dest = JOB_CONFIG_LOCAL["execution"]["environments"]["planemo_dest"]
|
1325 |
| - planemo_dest["docker_enabled"] = kwds.get("docker", False) |
1326 |
| - planemo_dest["docker_sudo"] = kwds.get("docker_sudo", False) |
1327 |
| - planemo_dest["docker_sudo_cmd"] = kwds.get("docker_sudo_cmd", docker_util.DEFAULT_SUDO_COMMAND) |
1328 |
| - planemo_dest["docker_cmd"] = kwds.get("docker_cmd", docker_util.DEFAULT_DOCKER_COMMAND) |
1329 |
| - |
1330 |
| - docker_host = kwds.get("docker_host", docker_util.DEFAULT_HOST) |
1331 |
| - if docker_host: |
1332 |
| - planemo_dest["docker_host"] = docker_host |
1333 |
| - |
1334 |
| - volumes = list(kwds.get("docker_extra_volume") or []) |
1335 |
| - if test_data_dir: |
1336 |
| - volumes.append(f"{test_data_dir}:ro") |
1337 |
| - |
1338 |
| - docker_volumes_str = "$defaults" |
1339 |
| - if volumes: |
1340 |
| - # exclude tool directories, these are mounted :ro by $defaults |
1341 |
| - all_tool_dirs = {os.path.dirname(tool_path) for tool_path in all_tool_paths} |
1342 |
| - extra_volumes_str = ",".join(str(v) for v in create_docker_volumes(volumes) if v.path not in all_tool_dirs) |
1343 |
| - docker_volumes_str = f"{docker_volumes_str},{extra_volumes_str}" |
1344 |
| - planemo_dest["docker_volumes"] = docker_volumes_str |
| 1324 | + |
| 1325 | + for container_type in ["docker", "singularity"]: |
| 1326 | + if not kwds.get(container_type, False): |
| 1327 | + continue |
| 1328 | + planemo_dest[f"{container_type}_enabled"] = kwds.get(container_type, False) |
| 1329 | + planemo_dest[f"{container_type}_sudo"] = kwds.get(f"{container_type}_sudo", False) |
| 1330 | + planemo_dest[f"{container_type}_sudo_cmd"] = kwds.get( |
| 1331 | + f"{container_type}_sudo_cmd", |
| 1332 | + docker_util.DEFAULT_SUDO_COMMAND |
| 1333 | + if container_type == "docker" |
| 1334 | + else singularity_util.DEFAULT_SUDO_COMMAND, |
| 1335 | + ) |
| 1336 | + planemo_dest[f"{container_type}_cmd"] = kwds.get( |
| 1337 | + f"{container_type}_cmd", |
| 1338 | + docker_util.DEFAULT_DOCKER_COMMAND |
| 1339 | + if container_type == "docker" |
| 1340 | + else singularity_util.DEFAULT_SINGULARITY_COMMAND, |
| 1341 | + ) |
| 1342 | + if container_type == "docker": |
| 1343 | + docker_host = kwds.get("docker_host", docker_util.DEFAULT_HOST) |
| 1344 | + if docker_host: |
| 1345 | + planemo_dest["docker_host"] = docker_host |
| 1346 | + |
| 1347 | + volumes = list(kwds.get(f"{container_type}_extra_volume") or []) |
| 1348 | + if test_data_dir: |
| 1349 | + volumes.append(f"{test_data_dir}:ro") |
| 1350 | + volumes_str = "$defaults" |
| 1351 | + if volumes: |
| 1352 | + # exclude tool directories, these are mounted :ro by $defaults |
| 1353 | + all_tool_dirs = {os.path.dirname(tool_path) for tool_path in all_tool_paths} |
| 1354 | + extra_volumes_str = ",".join( |
| 1355 | + str(v) for v in create_docker_volumes(volumes) if v.path not in all_tool_dirs |
| 1356 | + ) |
| 1357 | + volumes_str = f"{volumes_str},{extra_volumes_str}" |
| 1358 | + planemo_dest[f"{container_type}_volumes"] = volumes_str |
| 1359 | + break |
| 1360 | + |
1345 | 1361 | JOB_CONFIG_LOCAL["execution"]["environments"]["planemo_dest"] = planemo_dest
|
1346 | 1362 | with open(job_config_file, "w") as job_config_fh:
|
1347 | 1363 | ordered_dump(JOB_CONFIG_LOCAL, job_config_fh)
|
|
0 commit comments