-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1076 from simonbray/gxwf-integration
Integrate some features from gxwf
- Loading branch information
Showing
21 changed files
with
481 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Module describing the planemo ``create_alias`` command.""" | ||
import click | ||
|
||
from planemo import options | ||
from planemo.cli import command_function | ||
from planemo.galaxy import profiles | ||
from planemo.io import info | ||
|
||
try: | ||
import namesgenerator | ||
except ImportError: | ||
namesgenerator = None | ||
|
||
|
||
@click.command('create_alias') | ||
@click.argument( | ||
"obj", | ||
metavar="OBJ", | ||
type=click.STRING, | ||
) | ||
@options.alias_option() | ||
@options.profile_option(required=True) | ||
@command_function | ||
def cli(ctx, alias, obj, profile, **kwds): | ||
""" | ||
Add an alias for a path or a workflow or dataset ID. Aliases are associated with a particular planemo profile. | ||
""" | ||
if not alias: | ||
if not namesgenerator: | ||
raise ImportError(("Random generation of aliases requires installation of the namesgenerator package." | ||
"Either install this, or specify the alias name with --alias.")) | ||
alias = namesgenerator.get_random_name() | ||
|
||
exit_code = profiles.create_alias(ctx, alias, obj, profile) | ||
info("Alias {} created.".format(alias)) | ||
ctx.exit(exit_code) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Module describing the planemo ``delete_alias`` command.""" | ||
import click | ||
|
||
from planemo import options | ||
from planemo.cli import command_function | ||
from planemo.galaxy import profiles | ||
from planemo.io import error, info | ||
|
||
try: | ||
from tabulate import tabulate | ||
except ImportError: | ||
tabulate = None # type: ignore | ||
|
||
|
||
@click.command('delete_alias') | ||
@options.alias_option(required=True) | ||
@options.profile_option(required=True) | ||
@command_function | ||
def cli(ctx, alias, profile, **kwds): | ||
""" | ||
List aliases for a path or a workflow or dataset ID. Aliases are associated with a particular planemo profile. | ||
""" | ||
info("Looking for profiles...") | ||
exit_code = profiles.delete_alias(ctx, alias, profile) | ||
if exit_code == 0: | ||
info('Alias {} was successfully deleted from profile {}'.format(alias, profile)) | ||
else: | ||
error('Alias {} does not exist, so was not deleted from profile {}'.format(alias, profile)) | ||
|
||
ctx.exit(exit_code) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Module describing the planemo ``list_alias`` command.""" | ||
import json | ||
|
||
import click | ||
|
||
from planemo import options | ||
from planemo.cli import command_function | ||
from planemo.galaxy import profiles | ||
from planemo.io import info | ||
|
||
try: | ||
from tabulate import tabulate | ||
except ImportError: | ||
tabulate = None # type: ignore | ||
|
||
|
||
@click.command('list_alias') | ||
@options.profile_option(required=True) | ||
@command_function | ||
def cli(ctx, profile, **kwds): | ||
""" | ||
List aliases for a path or a workflow or dataset ID. Aliases are associated with a particular planemo profile. | ||
""" | ||
info("Looking for profiles...") | ||
aliases = profiles.list_alias(ctx, profile) | ||
if tabulate: | ||
print(tabulate({"Alias": aliases.keys(), "Object": aliases.values()}, headers="keys")) | ||
else: | ||
print(json.dumps(aliases, indent=4, sort_keys=True)) | ||
|
||
info("{} aliases were found for profile {}.".format(len(aliases), profile)) | ||
|
||
ctx.exit(0) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"""Module describing the planemo ``list_invocations`` command.""" | ||
import json | ||
|
||
import click | ||
|
||
from planemo import options | ||
from planemo.cli import command_function | ||
from planemo.galaxy import profiles | ||
from planemo.galaxy.api import get_invocations | ||
from planemo.galaxy.profiles import translate_alias | ||
from planemo.io import error, info | ||
|
||
try: | ||
from tabulate import tabulate | ||
except ImportError: | ||
tabulate = None # type: ignore | ||
|
||
|
||
@click.command('list_invocations') | ||
@click.argument( | ||
"workflow_id", | ||
type=click.STRING, | ||
) | ||
@options.profile_option(required=True) | ||
@command_function | ||
def cli(ctx, workflow_id, **kwds): | ||
""" | ||
Get a list of invocations for a particular workflow ID or alias. | ||
""" | ||
workflow_id = translate_alias(ctx, workflow_id, kwds.get('profile')) | ||
info("Looking for invocations for workflow {}...".format(workflow_id)) | ||
workflow_id = profiles.translate_alias(ctx, workflow_id, kwds.get('profile')) | ||
profile = profiles.ensure_profile(ctx, kwds.get('profile')) | ||
|
||
invocations = get_invocations(url=profile['galaxy_url'], key=profile['galaxy_admin_key'] or profile['galaxy_user_key'], workflow_id=workflow_id) | ||
if tabulate: | ||
state_colors = { | ||
'ok': '\033[92m', # green | ||
'running': '\033[93m', # yellow | ||
'error': '\033[91m', # red | ||
'paused': '\033[96m', # cyan | ||
'deleted': '\033[95m', # magenta | ||
'deleted_new': '\033[95m', # magenta | ||
'new': '\033[96m', # cyan | ||
'queued': '\033[93m', # yellow | ||
} | ||
print(tabulate({ | ||
"Invocation ID": invocations.keys(), | ||
"Jobs status": [', '.join(['{}{} jobs {}\033[0m'.format(state_colors[k], v, k) for k, v in inv['states'].items()] | ||
) for inv in invocations.values()], | ||
"Invocation report URL": ['{}/workflows/invocations/report?id={}'.format(profile['galaxy_url'].strip('/'), inv_id | ||
) for inv_id in invocations], | ||
"History URL": ['{}/histories/view?id={}'.format(profile['galaxy_url'].strip('/'), invocations[inv_id]['history_id'] | ||
) for inv_id in invocations] | ||
}, headers="keys")) | ||
else: | ||
error("The tabulate package is not installed, invocations could not be listed correctly.") | ||
print(json.dumps(invocations, indent=4, sort_keys=True)) | ||
info("{} invocations found.".format(len(invocations))) | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.