diff --git a/HISTORY.rst b/HISTORY.rst index 10dd3db62..9a8fa85fb 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,7 +9,8 @@ History 0.50.0.dev0 --------------------- - +* Fixes and small CLI tweaks to get the Docker Galaxy container working as an ``--engine`` for the + run, serve, and test commands. --------------------- 0.49.2 (2018-05-09) diff --git a/planemo/galaxy/config.py b/planemo/galaxy/config.py index 547c326b8..f07dafc66 100644 --- a/planemo/galaxy/config.py +++ b/planemo/galaxy/config.py @@ -11,6 +11,7 @@ from tempfile import mkdtemp import click +from galaxy.containers.docker_model import DockerVolume from galaxy.tools.deps import docker_util from galaxy.tools.deps.commands import argv_to_str from galaxy.util import unicodify @@ -261,6 +262,11 @@ def galaxy_config(ctx, runnables, **kwds): yield config +def simple_docker_volume(path): + path = os.path.abspath(path) + return DockerVolume("%s:%s:rw" % (path, path)) + + @contextlib.contextmanager def docker_galaxy_config(ctx, runnables, for_tests=False, **kwds): """Set up a ``GalaxyConfig`` for Docker container.""" @@ -286,7 +292,7 @@ def config_join(*args): # TODO: remap these. tool_volumes = [] for tool_directory in tool_directories: - volume = docker_util.DockerVolume(tool_directory) + volume = simple_docker_volume(tool_directory) tool_volumes.append(volume) empty_tool_conf = config_join("empty_tool_conf.xml") @@ -316,7 +322,6 @@ def config_join(*args): properties.update(dict( tool_config_file=tool_config_file, tool_sheds_config_file=sheds_config_path, - amqp_internal_connection="sqlalchemy+sqlite://", migrated_tools_config=empty_tool_conf, )) @@ -335,10 +340,15 @@ def config_join(*args): _build_test_env(properties, env) docker_target_kwds = docker_host_args(**kwds) - volumes = tool_volumes + [docker_util.DockerVolume(config_directory)] + volumes = tool_volumes + [simple_docker_volume(config_directory)] export_directory = kwds.get("export_directory", None) if export_directory is not None: - volumes.append(docker_util.DockerVolume(export_directory, "/export")) + volumes.append(DockerVolume("%s:/export:rw" % export_directory)) + + # TODO: Allow this to real Docker volumes and allow multiple. + extra_volume = kwds.get("docker_extra_volume") + if extra_volume: + volumes.append(simple_docker_volume(extra_volume)) yield DockerGalaxyConfig( ctx, config_directory, @@ -452,7 +462,6 @@ def config_join(*args): ftp_upload_dir=test_data_dir or os.path.abspath('.'), ftp_upload_site="Test Data", check_upload_content="False", - allow_path_paste="True", tool_dependency_dir=dependency_dir, file_path=file_path, new_file_path="${temp_directory}/tmp", @@ -570,6 +579,7 @@ def _shared_galaxy_properties(config_directory, kwds, for_tests): 'expose_dataset_path': "True", 'cleanup_job': 'never', 'collect_outputs_from': "job_working_directory", + 'allow_path_paste': "True", 'check_migrate_tools': "False", 'use_cached_dependency_manager': str(kwds.get("conda_auto_install", False)), 'brand': kwds.get("galaxy_brand", DEFAULT_GALAXY_BRAND), @@ -848,6 +858,7 @@ def __init__( def kill(self): """Kill planemo container...""" kill_command = docker_util.kill_command( + self.server_name, **self.docker_target_kwds ) return shell(kill_command) @@ -861,7 +872,7 @@ def startup_command(self, ctx, **kwds): daemon = kwds.get("daemon", False) daemon_str = "" if not daemon else " -d" docker_run_extras = "-p %s:80%s" % (self.port, daemon_str) - env_directives = ["%s=%s" % item for item in self.env.items()] + env_directives = ["%s='%s'" % item for item in self.env.items()] image = kwds.get("docker_galaxy_image", "bgruening/galaxy-stable") run_command = docker_util.build_docker_run_command( "", image, @@ -891,6 +902,7 @@ def startup_command(self, ctx, **kwds): @property def log_contents(self): logs_command = docker_util.logs_command( + self.server_name, **self.docker_target_kwds ) output, _ = communicate( diff --git a/planemo/network_util.py b/planemo/network_util.py index e3fc028a4..ba0ff1045 100644 --- a/planemo/network_util.py +++ b/planemo/network_util.py @@ -1,4 +1,8 @@ import socket +try: + from http.client import BadStatusLine +except ImportError: + from httplib import BadStatusLine from time import time as now from six.moves.urllib.error import URLError @@ -27,6 +31,8 @@ def wait_http_service(url, timeout=None): kwds = {} if timeout is None else dict(timeout=next_timeout) urlopen(url, **kwds) return True + except BadStatusLine: + pass except URLError: pass diff --git a/planemo/options.py b/planemo/options.py index 6371c3175..31586ed11 100644 --- a/planemo/options.py +++ b/planemo/options.py @@ -378,11 +378,28 @@ def install_galaxy_option(): def docker_galaxy_image_option(): return planemo_option( "--docker_galaxy_image", - default="bgruening/galaxy-stable", + default="quay.io/bgruening/galaxy", use_global_config=True, help=("Docker image identifier for docker-galaxy-flavor used if " "engine type is specified as ``docker-galaxy``. Defaults to " - "to bgruening/galaxy-stable.") + "to quay.io/bgruening/galaxy.") + ) + + +def docker_extra_volume_option(): + arg_type = click.Path( + exists=True, + file_okay=True, + dir_okay=True, + readable=True, + resolve_path=True, + ) + return planemo_option( + "--docker_extra_volume", + type=arg_type, + default=None, + use_global_config=True, + help=("Extra path to mount if --engine docker.") ) @@ -1062,6 +1079,7 @@ def galaxy_serve_options(): serve_engine_option(), non_strict_cwl_option(), docker_galaxy_image_option(), + docker_extra_volume_option(), galaxy_config_options(), daemon_option(), pid_file_option(), @@ -1159,6 +1177,7 @@ def engine_options(): non_strict_cwl_option(), cwltool_no_container_option(), docker_galaxy_image_option(), + docker_extra_volume_option(), ignore_dependency_problems_option(), galaxy_url_option(), galaxy_admin_key_option(), diff --git a/requirements.txt b/requirements.txt index 2789935f3..89c23c780 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,6 @@ virtualenv lxml gxformat2>=0.2.0 ephemeris>=0.8 -galaxy-lib>=18.5.5 +galaxy-lib>=18.5.10 html5lib>=0.9999999,!=0.99999999,!=0.999999999,!=1.0b10,!=1.0b09 cwltool==1.0.20170828135420