diff --git a/lib/galaxy/tool_util/toolbox/base.py b/lib/galaxy/tool_util/toolbox/base.py index 39fc18c68f01..4529f85d40db 100644 --- a/lib/galaxy/tool_util/toolbox/base.py +++ b/lib/galaxy/tool_util/toolbox/base.py @@ -95,7 +95,8 @@ def __init__(self, toolbox: "AbstractToolBox"): self.__toolbox = toolbox def has_tool(self, tool_id: str) -> bool: - return tool_id in self.__toolbox._tools_by_id + toolbox = self.__toolbox + return tool_id in toolbox._tools_by_id or tool_id in toolbox._tools_by_old_id def get_tool(self, tool_id: str): return self.__toolbox.get_tool(tool_id) @@ -153,6 +154,7 @@ def __init__( # so each will be present once in the above dictionary. The following # dictionary can instead hold multiple tools with different versions. self._tool_versions_by_id = {} + self._tools_by_old_id = {} self._workflows_by_id = {} # Cache for tool's to_dict calls specific to toolbox. Invalidates on toolbox reload. self._tool_to_dict_cache = {} @@ -710,9 +712,8 @@ def get_tool(self, tool_id, tool_version=None, get_all_versions=False, exact=Fal rval.append(lineage_tool) if not rval: # still no tool, do a deeper search and try to match by old ids - for tool in self._tools_by_id.values(): - if tool.old_id == tool_id: - rval.append(tool) + if tool_id in self._tools_by_old_id: + rval.extend(self._tools_by_old_id[tool_id]) if get_all_versions and tool_id in self._tool_versions_by_id: for tool in self._tool_versions_by_id[tool_id].values(): if tool not in rval: @@ -1152,6 +1153,10 @@ def register_tool(self, tool): self._tools_by_id[tool_id] = tool else: self._tools_by_id[tool_id] = tool + old_id = tool.old_id + if old_id not in self._tools_by_old_id: + self._tools_by_old_id[old_id] = [] + self._tools_by_old_id[old_id].append(tool) def package_tool(self, trans, tool_id): """ @@ -1211,6 +1216,7 @@ def remove_tool_by_id(self, tool_id, remove_from_panel=True): else: tool = self._tools_by_id[tool_id] del self._tools_by_id[tool_id] + self._tools_by_old_id[tool.old_id].remove(tool) tool_cache = getattr(self.app, "tool_cache", None) if tool_cache: tool_cache.expire_tool(tool_id) diff --git a/test/integration/panel_views_1/custom_6.yml b/test/integration/panel_views_1/custom_6.yml index 9567ba324135..b414f72254e5 100644 --- a/test/integration/panel_views_1/custom_6.yml +++ b/test/integration/panel_views_1/custom_6.yml @@ -2,7 +2,7 @@ name: Custom Panel in a New Section type: generic items: - type: section - name: My Completely New Sectin + name: My Completely New Section items: - type: label text: The Start diff --git a/test/integration/test_repository_operations.py b/test/integration/test_repository_operations.py index 4a1523090e06..82ff3f389996 100644 --- a/test/integration/test_repository_operations.py +++ b/test/integration/test_repository_operations.py @@ -123,9 +123,7 @@ def _uninstall_repository(self): assert tool["version"] == "0.0.2" self.uninstall_repository(REPO.owner, REPO.name, REPO.changeset) response = self.get_tool(assert_ok=False) - assert ( - "err_msg" in response - ), f"Expected an error message after tool install but response was {response.content}" + assert "err_msg" in response, f"Expected an error message after tool install but response was {response}" assert response["err_msg"] assert self.get_installed_repository_for(REPO.owner, REPO.name, REPO.changeset) is None