Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement shed serve and test commands, other enhancements. #213

Merged
merged 6 commits into from
May 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion planemo/commands/cmd_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@click.command('lint')
@options.optional_tools_arg(-1)
@options.optional_tools_arg(multiple=True)
@options.report_level_option()
@options.fail_level_option()
@options.skip_option()
Expand Down
17 changes: 4 additions & 13 deletions planemo/commands/cmd_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@


@click.command('serve')
@options.optional_tools_arg()
@options.galaxy_root_option()
@options.galaxy_port_option()
@options.install_galaxy_option()
@options.no_cache_galaxy_option()
@options.no_cleanup_option()
@options.test_data_option()
@options.dependency_resolvers_option()
@options.job_config_option()
@options.tool_dependency_dir_option()
@options.brew_dependency_resolution()
@options.optional_tools_arg(multiple=True)
@options.galaxy_serve_options()
@pass_context
def cli(ctx, path, **kwds):
def cli(ctx, paths, **kwds):
"""Launch a Galaxy instance with the specified tool in the tool panel.

The Galaxy tool panel will include just the referenced tool or tools (by
Expand All @@ -36,4 +27,4 @@ def cli(ctx, path, **kwds):
proof yet so please careful and do not try this against production Galaxy
instances.
"""
galaxy_serve.serve(ctx, path, **kwds)
galaxy_serve.serve(ctx, paths, **kwds)
14 changes: 3 additions & 11 deletions planemo/commands/cmd_shed_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,9 @@


@click.command("shed_create")
@options.shed_project_arg()
@options.shed_owner_option()
@options.shed_name_option()
@options.shed_target_option()
@options.shed_key_option()
@options.shed_email_option()
@options.shed_password_option()
@options.recursive_shed_option()
@options.shed_fail_fast_option()
@options.shed_publish_options()
@pass_context
def cli(ctx, path, **kwds):
def cli(ctx, paths, **kwds):
"""Create a repository in a Galaxy Tool Shed from a ``.shed.yml`` file.
"""
tsi = shed.tool_shed_client(ctx, **kwds)
Expand All @@ -37,5 +29,5 @@ def create(realized_reposiotry):
else:
return 1

exit_code = shed.for_each_repository(ctx, create, path, **kwds)
exit_code = shed.for_each_repository(ctx, create, paths, **kwds)
sys.exit(exit_code)
11 changes: 3 additions & 8 deletions planemo/commands/cmd_shed_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@


@click.command("shed_diff")
@options.shed_project_arg()
@options.shed_owner_option()
@options.shed_name_option()
@options.shed_target_option()
@options.shed_fail_fast_option()
@options.shed_read_options()
@click.option(
"-o", "--output",
type=click.Path(file_okay=True, resolve_path=True),
Expand All @@ -34,9 +30,8 @@
help="Do not attempt smart diff of XML to filter out attributes "
"populated by the Tool Shed.",
)
@options.recursive_shed_option()
@pass_context
def cli(ctx, path, **kwds):
def cli(ctx, paths, **kwds):
"""Produce diff between local repository and Tool Shed contents.

By default, this will produce a diff between this repository and what
Expand All @@ -58,5 +53,5 @@ def cli(ctx, path, **kwds):
def diff(realized_repository):
return shed.diff_repo(ctx, realized_repository, **kwds)

exit_code = shed.for_each_repository(ctx, diff, path, **kwds)
exit_code = shed.for_each_repository(ctx, diff, paths, **kwds)
sys.exit(exit_code)
11 changes: 3 additions & 8 deletions planemo/commands/cmd_shed_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


@click.command("shed_download")
@options.shed_project_arg()
@options.shed_read_options()
@click.option(
'--destination',
default="shed_download.tar.gz",
Expand All @@ -28,13 +28,8 @@
"created as shed_download_<name>.tar.gz by default for instance, "
"simpler repositories will just be downloaded to the specified file."
)
@options.shed_owner_option()
@options.shed_name_option()
@options.shed_target_option()
@options.recursive_shed_option()
@options.shed_fail_fast_option()
@pass_context
def cli(ctx, path, **kwds):
def cli(ctx, paths, **kwds):
"""Download a tool repository as a tarball from the tool shed and extract
to the specified directory.
"""
Expand All @@ -43,5 +38,5 @@ def cli(ctx, path, **kwds):
def download(realized_repository):
return shed.download_tarball(ctx, tsi, realized_repository, **kwds)

exit_code = shed.for_each_repository(ctx, download, path, **kwds)
exit_code = shed.for_each_repository(ctx, download, paths, **kwds)
sys.exit(exit_code)
3 changes: 1 addition & 2 deletions planemo/commands/cmd_shed_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
help='Specify repository category for .shed.yml (may specify multiple).',
type=click.Choice(shed.CURRENT_CATEGORIES)
)
@options.shed_owner_option()
@options.shed_name_option()
@options.shed_repo_options()
@options.force_option()
@pass_context
def cli(ctx, path, **kwds):
Expand Down
8 changes: 3 additions & 5 deletions planemo/commands/cmd_shed_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@click.command('shed_lint')
@options.shed_project_arg()
@options.shed_realization_options()
@options.report_level_option()
@options.fail_level_option()
@options.click.option(
Expand All @@ -18,15 +18,13 @@
help=("Lint tools discovered in the process of linting repositories.")
)
@options.lint_xsd_option()
@options.recursive_shed_option()
@options.shed_fail_fast_option()
@pass_context
def cli(ctx, path, **kwds):
def cli(ctx, paths, **kwds):
"""Check a Tool Shed repository for common problems.
"""
def lint(realized_repository):
return shed_lint.lint_repository(ctx, realized_repository, **kwds)

kwds["fail_on_missing"] = False
exit_code = shed.for_each_repository(ctx, lint, path, **kwds)
exit_code = shed.for_each_repository(ctx, lint, paths, **kwds)
sys.exit(exit_code)
30 changes: 30 additions & 0 deletions planemo/commands/cmd_shed_serve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
"""
import time
import click

from planemo.cli import pass_context
from planemo import options
from planemo import galaxy_serve
from planemo import shed
from planemo import io


@click.command("shed_serve")
@options.shed_read_options()
@options.galaxy_run_options()
@click.option(
"--skip_dependencies",
is_flag=True,
help="Do not install shed dependencies as part of repository installation."
)
@pass_context
def cli(ctx, paths, **kwds):
""" Serve a transient Galaxy instance after installing repositories
from a remote Tool Shed.
"""
install_args_list = shed.install_arg_lists(ctx, paths, **kwds)
with galaxy_serve.shed_serve(ctx, install_args_list, **kwds) as config:
gx_url = "http://localhost:%d/" % config.port
io.info("Galaxy running with tools installed at %s" % gx_url)
time.sleep(1000000)
51 changes: 51 additions & 0 deletions planemo/commands/cmd_shed_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
"""
import socket
import sys

import click

from planemo.cli import pass_context
from planemo import options
from planemo import galaxy_serve
from planemo import shed
from planemo import galaxy_test


@click.command("shed_test")
@options.shed_read_options()
@options.galaxy_target_options()
@options.test_options()
@click.option(
"--skip_dependencies",
is_flag=True,
help="Do not install shed dependencies as part of repository installation."
)
@pass_context
def cli(ctx, paths, **kwds):
""" Serve a transient Galaxy instance after installing repositories
from a remote Tool Shed.
"""
galaxy_test.process_defaults(ctx, kwds)
install_args_list = shed.install_arg_lists(ctx, paths, **kwds)
port = get_free_port()
kwds["port"] = port
return_code = 1
with galaxy_serve.shed_serve(ctx, install_args_list, **kwds) as config:
config.kill()
return_code = galaxy_test.run_in_config(
ctx,
config,
installed=True,
**kwds
)
if return_code:
sys.exit(return_code)


def get_free_port():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('localhost', 0))
port = sock.getsockname()[1]
sock.close()
return port
14 changes: 3 additions & 11 deletions planemo/commands/cmd_shed_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@


@click.command("shed_upload")
@options.shed_project_arg()
@options.shed_publish_options()
@click.option(
'-m',
'--message',
help="Commit message for tool shed upload."
)
@options.shed_owner_option()
@options.shed_name_option()
@options.shed_target_option()
@options.shed_key_option()
@options.shed_email_option()
@options.shed_password_option()
@click.option(
'--tar_only',
is_flag=True,
Expand All @@ -56,14 +50,12 @@
"'difference' (only attributes populated by the shed would would "
"be updated.)"
)
@options.recursive_shed_option()
@options.shed_fail_fast_option()
@pass_context
def cli(ctx, path, **kwds):
def cli(ctx, paths, **kwds):
"""Handle possible recursion through paths for uploading files to a toolshed
"""
def upload(realized_repository):
return shed.upload_repository(ctx, realized_repository, **kwds)

exit_code = shed.for_each_repository(ctx, upload, path, **kwds)
exit_code = shed.for_each_repository(ctx, upload, paths, **kwds)
sys.exit(exit_code)
Loading