Skip to content

Commit

Permalink
Create links only for inputs of type data
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Aug 25, 2023
1 parent 14d1a0f commit e98abeb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
22 changes: 16 additions & 6 deletions server/galaxyls/services/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from galaxyls.services.tools.document import GalaxyToolXmlDocument
from galaxyls.services.xml.document import XmlDocument
from galaxyls.services.xml.nodes import XmlElement
from galaxyls.services.xml.utils import convert_document_offsets_to_range


Expand All @@ -20,18 +21,17 @@ def _get_test_data_file_links(self, tool: GalaxyToolXmlDocument) -> List[Documen
for test in tool.get_tests():
params = filter(lambda e: e.name == "param", test.elements)
for param in params:
value_attr = param.attributes.get("value")
if value_attr is None or value_attr.value is None:
value_attribute = param.attributes.get("value")
filename = param.get_attribute_value("value")
if not value_attribute or not value_attribute.value or not filename:
# Must have a value
continue

filename = value_attr.get_value()
if filename is None or "." not in filename:
# Must be a filename with extension
if not self._is_data_input_param(param, tool):
continue

test_data_file_path = tool.get_test_data_path() / filename
start_offset, end_offset = value_attr.value.get_unquoted_content_offsets()
start_offset, end_offset = value_attribute.value.get_unquoted_content_offsets()
link_range = convert_document_offsets_to_range(tool.xml_document.document, start_offset, end_offset)
result.append(
DocumentLink(
Expand All @@ -40,3 +40,13 @@ def _get_test_data_file_links(self, tool: GalaxyToolXmlDocument) -> List[Documen
)
)
return result

def _is_data_input_param(self, param: XmlElement, tool: GalaxyToolXmlDocument) -> bool:
param_name = param.get_attribute_value("name")
inputs = tool.get_inputs()
for input in inputs:
input_name = input.get_attribute_value("name")
if input_name == param_name:
input_type = input.get_attribute_value("type")
return input_type == "data"
return False
11 changes: 11 additions & 0 deletions server/galaxyls/services/tools/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ def analyze_inputs(self) -> GalaxyToolInputTree:
inputs = self.find_element(INPUTS)
return GalaxyToolInputTree(inputs)

def get_inputs(self) -> List[XmlElement]:
"""Gets the inputs of this document as a list of elements.
Returns:
List[XmlElement]: The outputs defined in the document.
"""
outputs = self.find_element(INPUTS)
if outputs:
return outputs.elements
return []

def get_outputs(self) -> List[XmlElement]:
"""Gets the outputs of this document as a list of elements.
Expand Down

0 comments on commit e98abeb

Please sign in to comment.