Skip to content

Commit 2d28ece

Browse files
committed
Add --cwl and --cwl_galaxy_root options to serve command.
Allows experimental viewing CWL tools using planemo serve.
1 parent c3c33aa commit 2d28ece

5 files changed

Lines changed: 88 additions & 16 deletions

File tree

README.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,19 @@ For more information see the documentation for the `brew
218218
and `brew_env
219219
<http://planemo.readthedocs.org/en/latest/commands.html#brew_env-command>`__ commands.
220220

221+
--------------------------
222+
Common Workflow Language
223+
--------------------------
224+
225+
Planemo includes highly experimental support for running a subset of valid
226+
`Common Workflow Language`_ (CWL) tools using a fork of Galaxy enhanced to run
227+
CWL tools.
228+
229+
::
230+
231+
% planemo project_init --template cwl_draft2_spec
232+
% planemo serve --cwl cwl_draft2_spec/cat1-tool.cwl
233+
221234
.. _Galaxy: http://galaxyproject.org/
222235
.. _GitHub: https://github.com/
223236
.. _Docker: https://www.docker.com/
@@ -228,3 +241,4 @@ and `brew_env
228241
.. _`tools-devteam`: https://github.com/galaxyproject/tools-devteam
229242
.. _`tools-iuc`: https://github.com/galaxyproject/tools-iuc
230243
.. _Publishing to the Tool Shed: http://planemo.readthedocs.org/en/latest/publishing.html
244+
.. _Common Workfow Language: http://common-workflow-language.github.io

planemo/commands/cmd_serve.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
@click.command('serve')
99
@options.optional_tools_arg(multiple=True)
1010
@options.galaxy_serve_options()
11+
@options.enable_cwl_option()
12+
@options.galaxy_cwl_root_option()
1113
@pass_context
1214
def cli(ctx, paths, **kwds):
1315
"""Launch a Galaxy instance with the specified tool in the tool panel.

planemo/galaxy_config.py

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
DOWNLOADABLE_MIGRATION_VERSIONS = [127, 120, 117]
9393
LATEST_URL = DOWNLOADS_URL + "latest.sqlite"
9494

95+
PIP_INSTALL_CMD = "[ -d .venv ] && . .venv/bin/activate && pip install %s"
96+
9597
FAILED_TO_FIND_GALAXY_EXCEPTION = (
9698
"Failed to find Galaxy root directory - please explicitly specify one "
9799
"with --galaxy_root."
@@ -185,6 +187,7 @@ def config_join(*args):
185187
database_auto_migrate="True",
186188
cleanup_job="never",
187189
master_api_key="${master_api_key}",
190+
enable_beta_tool_formats="True",
188191
id_secret="${id_secret}",
189192
log_level="${log_level}",
190193
debug="${debug}",
@@ -381,11 +384,15 @@ def _check_galaxy(ctx, **kwds):
381384

382385

383386
def _find_galaxy_root(ctx, **kwds):
384-
galaxy_root = kwds.get("galaxy_root", None)
387+
root_prop = "galaxy_root"
388+
cwl = kwds.get("cwl", False)
389+
if cwl:
390+
root_prop = "cwl_galaxy_root"
391+
galaxy_root = kwds.get(root_prop, None)
385392
if galaxy_root:
386393
return galaxy_root
387-
elif ctx.global_config.get("galaxy_root", None):
388-
return ctx.global_config["galaxy_root"]
394+
elif ctx.global_config.get(root_prop, None):
395+
return ctx.global_config[root_prop]
389396
else:
390397
par_dir = os.getcwd()
391398
while True:
@@ -489,16 +496,17 @@ def _install_galaxy(ctx, config_directory, kwds):
489496

490497

491498
def _install_galaxy_via_download(config_directory, kwds):
492-
command = galaxy_run.DOWNLOAD_GALAXY + "; tar -zxvf dev | tail"
493-
_install_with_command(config_directory, command)
499+
branch = _galaxy_branch(kwds)
500+
tar_cmd = "tar -zxvf %s" % branch
501+
command = galaxy_run.DOWNLOAD_GALAXY + "; %s | tail" % tar_cmd
502+
_install_with_command(config_directory, command, kwds)
494503

495504

496505
def _install_galaxy_via_git(ctx, config_directory, kwds):
497-
_ensure_galaxy_repository_available(ctx)
498-
workspace = ctx.workspace
499-
gx_repo = os.path.join(workspace, "gx_repo")
500-
command = git.command_clone(ctx, gx_repo, "galaxy-dev")
501-
_install_with_command(config_directory, command)
506+
gx_repo = _ensure_galaxy_repository_available(ctx, kwds)
507+
branch = _galaxy_branch(kwds)
508+
command = git.command_clone(ctx, gx_repo, "galaxy-dev", branch=branch)
509+
_install_with_command(config_directory, command, kwds)
502510

503511

504512
def _build_eggs_cache(ctx, env, kwds):
@@ -511,27 +519,50 @@ def _build_eggs_cache(ctx, env, kwds):
511519
env["GALAXY_EGGS_PATH"] = eggs_path
512520

513521

514-
def _install_with_command(config_directory, command):
522+
def _galaxy_branch(kwds):
523+
# TODO: implement generic --branch argument
524+
cwl = kwds.get("cwl", False)
525+
branch = "cwl" if cwl else "dev"
526+
return branch
527+
528+
529+
def _install_with_command(config_directory, command, kwds):
530+
# TODO: --watchdog
531+
pip_installs = []
532+
if kwds.get("cwl", False):
533+
pip_installs.append("cwltool")
534+
if pip_installs:
535+
pip_install_command = PIP_INSTALL_CMD % " ".join(pip_installs)
536+
else:
537+
pip_install_command = ""
515538
install_cmds = [
516539
"cd %s" % config_directory,
517540
command,
518541
"cd galaxy-dev",
519542
"type virtualenv >/dev/null 2>&1 && virtualenv .venv",
543+
pip_install_command,
520544
galaxy_run.ACTIVATE_COMMAND,
521545
]
522-
shell(";".join(install_cmds))
546+
shell(";".join([c for c in install_cmds if c]))
523547

524548

525-
def _ensure_galaxy_repository_available(ctx):
549+
def _ensure_galaxy_repository_available(ctx, kwds):
526550
workspace = ctx.workspace
551+
cwl = kwds.get("cwl", False)
527552
gx_repo = os.path.join(workspace, "gx_repo")
553+
if cwl:
554+
gx_repo += "_cwl"
528555
if os.path.exists(gx_repo):
529556
# Attempt fetch - but don't fail if not interweb, etc...
530557
shell("git --git-dir %s fetch >/dev/null 2>&1" % gx_repo)
531558
else:
532-
remote_repo = "https://github.com/galaxyproject/galaxy"
559+
if cwl:
560+
remote_repo = "https://github.com/common-workflow-language/galaxy"
561+
else:
562+
remote_repo = "https://github.com/galaxyproject/galaxy"
533563
command = git.command_clone(ctx, remote_repo, gx_repo, bare=True)
534564
shell(command)
565+
return gx_repo
535566

536567

537568
def _build_env_for_galaxy(properties, template_args):

planemo/git.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
from planemo import io
55

66

7-
def command_clone(ctx, src, dest, bare=False):
7+
def command_clone(ctx, src, dest, bare=False, branch=None):
88
""" Take in ctx to allow more configurability down the road.
99
"""
1010
bare_arg = ""
1111
if bare:
1212
bare_arg = "--bare"
13-
return "git clone %s '%s' '%s'" % (bare_arg, src, dest)
13+
branch_arg = ""
14+
if branch is not None:
15+
branch_arg = "--branch '%s'" % branch
16+
cmd = "git clone %s %s '%s' '%s'" % (bare_arg, branch_arg, src, dest)
17+
return cmd
1418

1519

1620
def clone(*args, **kwds):

planemo/options.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ def galaxy_root_option():
4242
)
4343

4444

45+
def galaxy_cwl_root_option():
46+
return click.option(
47+
"--cwl_galaxy_root",
48+
type=click.Path(exists=True, file_okay=False, resolve_path=True),
49+
help=("Root of development galaxy directory to execute command with"
50+
" (must be branch of Galaxy with CWL support, this option"
51+
" is experimental and will be replaced with --galaxy_root when"
52+
" and if CWL support is merged into Galaxy."),
53+
)
54+
55+
4556
def galaxy_port_option():
4657
return click.option(
4758
"--port",
@@ -78,6 +89,16 @@ def dependency_resolvers_option():
7889
)
7990

8091

92+
def enable_cwl_option():
93+
return click.option(
94+
"--cwl",
95+
is_flag=True,
96+
help=("Configure Galaxy for use with CWL tool."
97+
" (this option is experimental and will be replaced when"
98+
" and if CWL support is merged into Galaxy."),
99+
)
100+
101+
81102
def brew_dependency_resolution():
82103
return click.option(
83104
"--brew_dependency_resolution",

0 commit comments

Comments
 (0)