Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Jul 2, 2024
1 parent 3b693e9 commit 2457f97
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions lib/galaxy/tools/stock.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
"""Reason about stock tools based on ToolSource abstractions."""

from pathlib import Path

from lxml.etree import XMLSyntaxError

# Set GALAXY_INCLUDES_ROOT from tool shed to point this at a Galaxy root
# (once we are running the tool shed from packages not rooted with Galaxy).
import galaxy.tools
from galaxy.tool_util.parser import get_tool_source
from galaxy.util import galaxy_root_path
from galaxy.util import galaxy_directory
from galaxy.util.resources import files


def stock_tool_paths():
yield from _walk_directory_for_tools(files(galaxy.tools))
yield from _walk_directory_for_tools(galaxy_root_path / "test" / "functional" / "tools")
yield from _walk_directory_for_tools(Path(galaxy_directory()) / "test" / "functional" / "tools")


def stock_tool_sources():
Expand All @@ -23,7 +25,6 @@ def stock_tool_sources():
continue



def _walk_directory_for_tools(path):
if path.is_file() and path.name.endswith(".xml"):
yield path
Expand Down
11 changes: 7 additions & 4 deletions lib/tool_shed/managers/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
tool_parameter_bundle_from_json,
ToolParameterBundleModel,
)
from galaxy.tools.stock import stock_tool_sources
from galaxy.tool_util.parser import (
get_tool_source,
ToolSource,
)
from galaxy.tools.stock import stock_tool_sources
from tool_shed.context import (
ProvidesRepositoriesContext,
SessionRequestContext,
Expand All @@ -38,7 +38,6 @@
from tool_shed.webapp.search.tool_search import ToolSearch
from .trs import trs_tool_id_to_repository_metadata


STOCK_TOOL_SOURCES: Optional[Dict[str, Dict[str, ToolSource]]] = None


Expand Down Expand Up @@ -123,7 +122,10 @@ def tool_source_for(
if "~" in trs_tool_id:
return _shed_tool_source_for(trans, trs_tool_id, tool_version, repository_clone_url)
else:
return _stock_tool_source_for(trs_tool_id, tool_version)
tool_source = _stock_tool_source_for(trs_tool_id, tool_version)
if tool_source is None:
raise ObjectNotFound()
return tool_source


def _shed_tool_source_for(
Expand Down Expand Up @@ -151,9 +153,10 @@ def _shed_tool_source_for(

def _stock_tool_source_for(tool_id: str, tool_version: str) -> Optional[ToolSource]:
_init_stock_tool_sources()
assert STOCK_TOOL_SOURCES
tool_version_sources = STOCK_TOOL_SOURCES.get(tool_id)
if tool_version_sources is None:
return
return None
return tool_version_sources.get(tool_version)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="gx_select_multiple" name="gx_select_multiple" version="1.0.0">
<tool id="gx_select_multiple_optional" name="gx_select_multiple_optional" version="1.0.0">
<command><![CDATA[
echo '$parameter' >> '$output'
]]></command>
Expand All @@ -16,10 +16,10 @@ echo '$parameter' >> '$output'
</outputs>
<tests>
<test>
<param name="parameter" value="12456" />
<param name="parameter" value="ex2" />
<output name="output">
<assert_contents>
<has_line line="12456" />
<has_line line="ex2" />
</assert_contents>
</output>
</test>
Expand Down

0 comments on commit 2457f97

Please sign in to comment.