From cd6172cef6f6cf86f0088c2118685d7e3e8f892e Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Tue, 11 Apr 2023 21:00:01 +0200 Subject: [PATCH] use yml job config --- planemo/galaxy/config.py | 80 ++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/planemo/galaxy/config.py b/planemo/galaxy/config.py index 6fd5e3e15..16be87ddf 100644 --- a/planemo/galaxy/config.py +++ b/planemo/galaxy/config.py @@ -26,6 +26,7 @@ TYPE_CHECKING, ) +from galaxy.util.yaml_util import ordered_dump from galaxy.tool_util.deps import docker_util from galaxy.tool_util.deps.container_volumes import DockerVolume from galaxy.util.commands import argv_to_str @@ -108,31 +109,29 @@ """ -JOB_CONFIG_LOCAL = """ - - - - - - - - ${require_container} - ${docker_enable} - ${docker_sudo} - ${docker_sudo_cmd} - ${docker_cmd} - ${docker_volumes} - ${docker_host_param} - - - false - - - - - - -""" +JOB_CONFIG_LOCAL = { + "runners": {"planemo_runner": {"load": "galaxy.jobs.runners.local:LocalJobRunner", "workers": 4}}, + "execution": { + "default": "planemo_dest", + "environments": { + "planemo_dest": { + "runner": "planemo_runner", + "docker_enabled": True, + "require_container": False, + "docker_enabled": False, + "docker_sudo": False, + "docker_sudo_cmd": docker_util.DEFAULT_SUDO_COMMAND, + "docker_cmd": docker_util.DEFAULT_DOCKER_COMMAND, + "docker_volumes": "$defaults", + }, + "upload_dest": {"runner": "planemo_runner", "docker_enabled": False}, + }, + }, + "tools": [ + {"id": "upload1", "environment": "upload_dest"}, + ], +} + REFGENIE_CONFIG_TEMPLATE = """ config_version: %s @@ -1319,16 +1318,19 @@ def _handle_job_config_file( ): job_config_file = kwds.get("job_config_file", None) if not job_config_file: - template_str = JOB_CONFIG_LOCAL job_config_file = os.path.join( config_directory, - "job_conf.xml", + "job_conf.yml", ) - docker_enable = str(kwds.get("docker", False)) + planemo_dest = JOB_CONFIG_LOCAL["execution"]["environments"]["planemo_dest"] + planemo_dest["docker_enabled"] = kwds.get("docker", False) + planemo_dest["docker_sudo"] = kwds.get("docker_sudo", False) + planemo_dest["docker_sudo_cmd"] = kwds.get("docker_sudo_cmd", docker_util.DEFAULT_SUDO_COMMAND) + planemo_dest["docker_cmd"] = kwds.get("docker_cmd", docker_util.DEFAULT_DOCKER_COMMAND) + docker_host = kwds.get("docker_host", docker_util.DEFAULT_HOST) - docker_host_param = "" if docker_host: - docker_host_param = f"""{docker_host}""" + planemo_dest["docker_host"] = docker_host volumes = list(kwds.get("docker_extra_volume") or []) if test_data_dir: @@ -1340,20 +1342,10 @@ def _handle_job_config_file( all_tool_dirs = {os.path.dirname(tool_path) for tool_path in all_tool_paths} extra_volumes_str = ",".join(str(v) for v in create_docker_volumes(volumes) if v.path not in all_tool_dirs) docker_volumes_str = f"{docker_volumes_str},{extra_volumes_str}" - - conf_contents = Template(template_str).safe_substitute( - { - "server_name": server_name, - "docker_enable": docker_enable, - "require_container": "false", - "docker_sudo": str(kwds.get("docker_sudo", False)), - "docker_sudo_cmd": str(kwds.get("docker_sudo_cmd", docker_util.DEFAULT_SUDO_COMMAND)), - "docker_cmd": str(kwds.get("docker_cmd", docker_util.DEFAULT_DOCKER_COMMAND)), - "docker_host_param": docker_host_param, - "docker_volumes": docker_volumes_str, - } - ) - write_file(job_config_file, conf_contents) + planemo_dest["docker_volumes"] = docker_volumes_str + JOB_CONFIG_LOCAL["execution"]["environments"]["planemo_dest"] = planemo_dest + with open(job_config_file, "w") as job_config_fh: + ordered_dump(JOB_CONFIG_LOCAL, job_config_fh) kwds["job_config_file"] = job_config_file