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

Fix bugs in tool shed tool API. #18558

Merged
merged 1 commit into from
Jul 17, 2024
Merged
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
9 changes: 8 additions & 1 deletion lib/tool_shed/managers/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from galaxy.exceptions import (
InternalServerError,
ObjectNotFound,
RequestParameterInvalidException,
)
from galaxy.tool_shed.metadata.metadata_generator import RepositoryMetadataToolDict
from galaxy.tool_shed.util.basic_util import remove_dir
Expand All @@ -28,6 +29,7 @@
ToolSource,
)
from galaxy.tools.stock import stock_tool_sources
from galaxy.util import relpath
from tool_shed.context import (
ProvidesRepositoriesContext,
SessionRequestContext,
Expand Down Expand Up @@ -82,6 +84,9 @@ def search(trans: SessionRequestContext, q: str, page: int = 1, page_size: int =
def get_repository_metadata_tool_dict(
trans: ProvidesRepositoriesContext, trs_tool_id: str, tool_version: str
) -> Tuple[RepositoryMetadata, RepositoryMetadataToolDict]:
if trs_tool_id.count("~") < 2:
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved
RequestParameterInvalidException(f"Invalid TRS tool id ({trs_tool_id})")

name, owner, tool_id = trs_tool_id.split("~", 3)
repository, metadata_by_version = trs_tool_id_to_repository_metadata(trans, trs_tool_id)
if tool_version not in metadata_by_version:
Expand Down Expand Up @@ -143,7 +148,9 @@ def _shed_tool_source_for(
cloned_ok, error_message = clone_repository(repository_clone_url, work_dir, str(ctx.rev()))
if error_message:
raise InternalServerError("Failed to materialize target repository revision")
path_to_tool = os.path.join(work_dir, tool_config)
repo_files_dir = repository_metadata.repository.repo_path(trans.app)
repo_rel_tool_path = relpath(tool_config, repo_files_dir)
path_to_tool = os.path.join(work_dir, repo_rel_tool_path)
tool_source = get_tool_source(path_to_tool)
return tool_source
finally:
Expand Down
Loading