Skip to content

Commit

Permalink
Implement profiles in sheds section of the ~/.planemo.yml.
Browse files Browse the repository at this point in the history
Each shed section can now have a username which will be used in lieu of the top-level shed_username in that config. Each shed section can now specify a URL - existing profiles (toolshed, testtoolshed, and local) will be assigned URLs automatically if they are specified.

But new profiles can be created with arbitrary names and used in conjunction with shed_target.
  • Loading branch information
jmchilton committed Oct 2, 2015
1 parent b095788 commit 8a13611
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 81 deletions.
6 changes: 5 additions & 1 deletion docs/.planemo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# password: <password>

sheds:
username: "<TODO>"
# For each Tool Shed you wish to target enter the API key
# or both email and password.
toolshed:
Expand All @@ -23,3 +22,8 @@ sheds:
key: "<TODO>"
#email: "<TODO>"
#password: "<TODO>"
custom_shed:
key: "<TODO>"
url: "http://customurl/"
#email: "<TODO>"
#password: "<TODO>"
6 changes: 3 additions & 3 deletions planemo/commands/cmd_shed_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
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)
shed_context = shed.get_shed_context(ctx, **kwds)

def create(realized_repository):
repo_id = realized_repository.find_repository_id(ctx, tsi)
repo_id = realized_repository.find_repository_id(ctx, shed_context)
if repo_id is None:
if realized_repository.create(ctx, tsi):
if realized_repository.create(ctx, shed_context):
info("Repository created")
if not kwds["skip_upload"]:
return shed.upload_repository(
Expand Down
4 changes: 2 additions & 2 deletions planemo/commands/cmd_shed_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def cli(ctx, paths, **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_context = shed.get_shed_context(ctx, read_only=True, **kwds)

def download(realized_repository):
return shed.download_tarball(ctx, tsi, realized_repository, **kwds)
return shed.download_tarball(ctx, shed_context, realized_repository, **kwds)

exit_code = shed.for_each_repository(ctx, download, paths, **kwds)
sys.exit(exit_code)
6 changes: 3 additions & 3 deletions planemo/commands/cmd_shed_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def cli(ctx, paths, **kwds):
The lower-level ``shed_upload`` command should be used instead if
the repository doesn't define complete metadata in a ``.shed.yml``.
"""
tsi = shed.tool_shed_client(ctx, **kwds)
shed_context = shed.get_shed_context(ctx, **kwds)

def update(realized_repository):
upload_ret_code = 0
Expand All @@ -63,10 +63,10 @@ def update(realized_repository):
error("Failed to update repository it does not exist "
"in target ToolShed.")
return upload_ret_code
repo_id = realized_repository.find_repository_id(ctx, tsi)
repo_id = realized_repository.find_repository_id(ctx, shed_context)
metadata_ok = True
if not kwds["skip_metadata"]:
metadata_ok = realized_repository.update(ctx, tsi, repo_id)
metadata_ok = realized_repository.update(ctx, shed_context, repo_id)
if metadata_ok:
info("Repository metadata updated.")
else:
Expand Down
6 changes: 3 additions & 3 deletions planemo/galaxy_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def config_join(*args):
database_location = config_join("galaxy.sqlite")
shed_tools_path = config_join("shed_tools")
sheds_config_path = _configure_sheds_config_file(
config_directory, **kwds
ctx, config_directory, **kwds
)
preseeded_database = True
master_api_key = kwds.get("master_api_key", "test_key")
Expand Down Expand Up @@ -450,11 +450,11 @@ def _search_tool_path_for(path, target, extra_paths=[]):
return None


def _configure_sheds_config_file(config_directory, **kwds):
def _configure_sheds_config_file(ctx, config_directory, **kwds):
if "shed_target" not in kwds:
kwds = kwds.copy()
kwds["shed_target"] = "toolshed"
shed_target_url = tool_shed_url(kwds)
shed_target_url = tool_shed_url(ctx, kwds)
contents = _sub(TOOL_SHEDS_CONF, {"shed_target_url": shed_target_url})
tool_sheds_conf = os.path.join(config_directory, "tool_sheds_conf.xml")
write_file(tool_sheds_conf, contents)
Expand Down
4 changes: 2 additions & 2 deletions planemo/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ def shed_target_option():
"-t",
"--shed_target",
help="Tool Shed to target (this can be 'toolshed', 'testtoolshed', "
"'local' (alias for http://localhost:9009/) or an arbitrary"
"url).",
"'local' (alias for http://localhost:9009/), an arbitrary url "
"or mappings defined ~/.planemo.yml.",
default=None,
callback=validate_shed_target_callback,
)
Expand Down
Loading

0 comments on commit 8a13611

Please sign in to comment.