forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework ParsedTool for reuse outside of the tool shed.
- Loading branch information
Showing
2 changed files
with
78 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""Define the ParsedTool model representing metadata extracted from a tool's source. | ||
This is abstraction exported by newer tool shed APIS (circa 2024) and should be sufficient | ||
for reasoning about tool state externally from Galaxy. | ||
""" | ||
|
||
from typing import ( | ||
List, | ||
Optional, | ||
) | ||
|
||
from pydantic import BaseModel | ||
|
||
from .parameters import ( | ||
input_models_for_tool_source, | ||
ToolParameterT, | ||
) | ||
from .parser.interface import ( | ||
Citation, | ||
ToolSource, | ||
XrefDict, | ||
) | ||
from .parser.output_models import ( | ||
from_tool_source, | ||
ToolOutput, | ||
) | ||
|
||
|
||
class ParsedTool(BaseModel): | ||
id: str | ||
version: Optional[str] | ||
name: str | ||
description: Optional[str] | ||
inputs: List[ToolParameterT] | ||
outputs: List[ToolOutput] | ||
citations: List[Citation] | ||
license: Optional[str] | ||
profile: Optional[str] | ||
edam_operations: List[str] | ||
edam_topics: List[str] | ||
xrefs: List[XrefDict] | ||
help: Optional[str] | ||
|
||
|
||
def parse_tool(tool_source: ToolSource) -> ParsedTool: | ||
id = tool_source.parse_id() | ||
version = tool_source.parse_version() | ||
name = tool_source.parse_name() | ||
description = tool_source.parse_description() | ||
inputs = input_models_for_tool_source(tool_source).input_models | ||
outputs = from_tool_source(tool_source) | ||
citations = tool_source.parse_citations() | ||
license = tool_source.parse_license() | ||
profile = tool_source.parse_profile() | ||
edam_operations = tool_source.parse_edam_operations() | ||
edam_topics = tool_source.parse_edam_topics() | ||
xrefs = tool_source.parse_xrefs() | ||
help = tool_source.parse_help() | ||
|
||
return ParsedTool( | ||
id=id, | ||
version=version, | ||
name=name, | ||
description=description, | ||
profile=profile, | ||
inputs=inputs, | ||
outputs=outputs, | ||
license=license, | ||
citations=citations, | ||
edam_operations=edam_operations, | ||
edam_topics=edam_topics, | ||
xrefs=xrefs, | ||
help=help, | ||
) |
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