Skip to content

Commit

Permalink
Merge pull request #813 from jmchilton/docker_galaxy_stable_fixes
Browse files Browse the repository at this point in the history
Fixes to get Docker Galaxy Stable running as an --engine again.
  • Loading branch information
jmchilton committed May 11, 2018
2 parents f402d0b + d9a2977 commit 1403471
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
3 changes: 2 additions & 1 deletion HISTORY.rst
Expand Up @@ -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)
Expand Down
24 changes: 18 additions & 6 deletions planemo/galaxy/config.py
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand All @@ -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")
Expand Down Expand Up @@ -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,
))

Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions 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
Expand Down Expand Up @@ -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

Expand Down
23 changes: 21 additions & 2 deletions planemo/options.py
Expand Up @@ -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.")
)


Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -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

0 comments on commit 1403471

Please sign in to comment.