-
Notifications
You must be signed in to change notification settings - Fork 85
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 #33 from galaxyproject/shed_diff
Implement shed_diff.
- Loading branch information
Showing
11 changed files
with
277 additions
and
39 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
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,47 @@ | ||
|
||
``shed_diff`` command | ||
=============================== | ||
|
||
This section is auto-generated from the help text for the planemo command | ||
``shed_diff``. This help message can be generated with ``planemo shed_diff | ||
--help``. | ||
|
||
**Usage**:: | ||
|
||
planemo shed_diff [OPTIONS] PROJECT | ||
|
||
**Help** | ||
|
||
Produce diff between local repository and Tool Shed contents. | ||
|
||
By default, this will produce a diff between this repository and what | ||
would be uploaded to the Tool Shed with the `shed_upload` command - but | ||
this command can be made to compare other combinations of repositories. | ||
Here are some examples:: | ||
|
||
% # diff for this repository and the main Tool Shed | ||
% planemo shed_diff | ||
% # diff for this repository and the test Tool Shed | ||
% planemo shed_diff --shed_target testtoolshed | ||
% # diff for the test Tool Shed and main Tool Shed | ||
% planemo shed_diff --shed_target_source testtoolshed | ||
% # diff for two an explicitly specified repositories (ignores | ||
% # current project's shed YAML file.) | ||
% planemo shed_diff --owner peterjc --name blast_rbh | ||
--shed_target_source testtoolshed | ||
|
||
**Options**:: | ||
|
||
|
||
--owner TEXT Tool Shed repository owner (username). | ||
--name TEXT Tool Shed repository name (defaults to the | ||
inferred tool directory name). | ||
--shed_target TEXT Tool Shed to target (this can be 'toolshed', | ||
'testtoolshed', 'local' (alias for | ||
http://localhost:9009/) or an arbitraryurl). | ||
--shed_target_source TEXT Source Tool Shed to diff against (will ignore | ||
local project info specified). To compare the | ||
main Tool Shed against the test, set this to | ||
testtoolshed. | ||
--help Show this message and exit. | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
""" | ||
""" | ||
import os | ||
import shutil | ||
import tempfile | ||
|
||
import click | ||
|
||
from planemo.cli import pass_context | ||
from planemo.io import shell | ||
from planemo import options | ||
from planemo import shed | ||
|
||
|
||
@click.command("shed_diff") | ||
@options.optional_project_arg(exists=True) | ||
@options.shed_owner_option() | ||
@options.shed_name_option() | ||
@options.shed_target_option() | ||
@click.option( | ||
'--shed_target_source', | ||
help="Source Tool Shed to diff against (will ignore local project info" | ||
" specified). To compare the main Tool Shed against the test, set" | ||
" this to testtoolshed.", | ||
default=None, | ||
) | ||
@pass_context | ||
def cli(ctx, path, **kwds): | ||
"""Produce diff between local repository and Tool Shed contents. | ||
By default, this will produce a diff between this repository and what | ||
would be uploaded to the Tool Shed with the `shed_upload` command - but | ||
this command can be made to compare other combinations of repositories. | ||
Here are some examples:: | ||
% # diff for this repository and the main Tool Shed | ||
% planemo shed_diff | ||
% # diff for this repository and the test Tool Shed | ||
% planemo shed_diff --shed_target testtoolshed | ||
% # diff for the test Tool Shed and main Tool Shed | ||
% planemo shed_diff --shed_target_source testtoolshed | ||
% # diff for two an explicitly specified repositories (ignores | ||
% # current project's shed YAML file.) | ||
% planemo shed_diff --owner peterjc --name blast_rbh | ||
--shed_target_source testtoolshed | ||
""" | ||
working = tempfile.mkdtemp(prefix="tool_shed_diff_") | ||
try: | ||
diff_in(ctx, working, path, **kwds) | ||
finally: | ||
shutil.rmtree(working) | ||
|
||
|
||
def diff_in(ctx, working, path, **kwds): | ||
shed_target_source = kwds.get("shed_target_source", None) | ||
|
||
label_a = "_%s_" % (shed_target_source if shed_target_source else "local") | ||
label_b = "_%s_" % kwds.get("shed_target", "B") | ||
|
||
mine = os.path.join(working, label_a) | ||
other = os.path.join(working, label_b) | ||
|
||
tsi = shed.tool_shed_client(ctx, read_only=True, **kwds) | ||
shed.download_tarball( | ||
ctx, | ||
tsi, | ||
path, | ||
destination=other, | ||
clean=True, | ||
**kwds | ||
) | ||
|
||
if shed_target_source: | ||
new_kwds = kwds.copy() | ||
new_kwds["shed_target"] = shed_target_source | ||
tsi = shed.tool_shed_client(ctx, read_only=True, **new_kwds) | ||
shed.download_tarball( | ||
ctx, | ||
tsi, | ||
path, | ||
destination=mine, | ||
clean=True, | ||
**new_kwds | ||
) | ||
else: | ||
tar_path = shed.build_tarball(path) | ||
cmd_template = 'mkdir "%s"; tar -xzf "%s" -C "%s"; rm -rf %s' | ||
shell(cmd_template % (mine, tar_path, mine, tar_path)) | ||
|
||
shell('cd "%s"; diff -r %s %s' % (working, label_a, label_b)) |
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,35 @@ | ||
""" | ||
""" | ||
import click | ||
|
||
from planemo.cli import pass_context | ||
from planemo import options | ||
from planemo import shed | ||
|
||
target_path = click.Path( | ||
file_okay=True, | ||
writable=True, | ||
resolve_path=True, | ||
) | ||
|
||
|
||
@click.command("shed_download") | ||
@options.optional_project_arg(exists=True) | ||
@click.option( | ||
'--destination', | ||
default="shed_download.tar.gz", | ||
type=target_path, | ||
help="Destination of tarball to download - if this doesn't end in 'gz' it " | ||
"will be treated as a directory to extract tool contents into" | ||
"(defaults to shed_download.tar.gz)." | ||
) | ||
@options.shed_owner_option() | ||
@options.shed_name_option() | ||
@options.shed_target_option() | ||
@pass_context | ||
def cli(ctx, path, **kwds): | ||
"""Download a tool repository as a tarball from the tool shed and extract | ||
to the specified directory. | ||
""" | ||
tsi = shed.tool_shed_client(ctx, read_only=True, **kwds) | ||
shed.download_tarball(ctx, tsi, path, **kwds) |
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.