Skip to content

Commit

Permalink
Work toward data column support in tool parameter meta models.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Aug 5, 2024
1 parent cb3ec1f commit 2f19d2c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/galaxy/tool_util/parameters/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
CwlStringParameterModel,
CwlUnionParameterModel,
DataCollectionParameterModel,
DataColumnParameterModel,
DataParameterModel,
DrillDownParameterModel,
FloatParameterModel,
Expand Down Expand Up @@ -159,6 +160,10 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT:
hierarchy=hierarchy,
options=static_options,
)
elif param_type == "data_column":
return DataColumnParameterModel(
name=input_source.parse_name(),
)
else:
raise Exception(f"Unknown Galaxy parameter type {param_type}")
elif input_type == "conditional":
Expand Down
16 changes: 16 additions & 0 deletions lib/galaxy/tool_util/parameters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,21 @@ def request_requires_value(self) -> bool:
return self.multiple and not self.optional


class DataColumnParameterModel(BaseGalaxyToolParameterModelDefinition):
parameter_type: Literal["gx_data_column"] = "gx_data_column"

@property
def py_type(self) -> Type:
return StrictInt

def pydantic_template(self, state_representation: StateRepresentationT) -> DynamicModelInformation:
return dynamic_model_information_from_py_type(self, self.py_type)

@property
def request_requires_value(self) -> bool:
return False


DiscriminatorType = Union[bool, str]


Expand Down Expand Up @@ -883,6 +898,7 @@ def request_requires_value(self) -> bool:
SelectParameterModel,
DataParameterModel,
DataCollectionParameterModel,
DataColumnParameterModel,
DirectoryUriParameterModel,
RulesParameterModel,
DrillDownParameterModel,
Expand Down
36 changes: 36 additions & 0 deletions test/functional/tools/parameters/gx_data_column.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<tool id="gx_data_column" name="gx_data_column" version="1.0.0">
<macros>
<import>macros.xml</import>
</macros>
<command><![CDATA[
echo 'parameter: $parameter' >> '$output'
]]></command>
<inputs>
<param name="ref_parameter" type="data" format="tabular" />
<param name="parameter" type="data_column" data_ref="ref_parameter" multiple="true" />
</inputs>
<expand macro="simple_text_output" />
<tests>
<test>
<param name="ref_parameter" value="2.tabular" />
<param name="parameter" value="1" />
<expand macro="assert_output">
<has_line line="parameter: 1"/>
</expand>
</test>
<test>
<param name="ref_parameter" value="2.tabular" />
<param name="parameter" value="2" />
<expand macro="assert_output">
<has_line line="parameter: 2"/>
</expand>
</test>
<!-- these parameters are implicitly optional -->
<test>
<param name="ref_parameter" value="2.tabular" />
<expand macro="assert_output">
<has_line line="parameter: 1"/>
</expand>
</test>
</tests>
</tool>
10 changes: 10 additions & 0 deletions test/unit/tool_util/parameter_specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,16 @@ gx_drill_down_exact:
- parameter: c
- parameter: {}

gx_data_column:
request_valid:
- { ref_parameter: {src: hda, id: abcdabcd}, parameter: 0 }
request_invalid:
- { ref_parameter: {src: hda, id: abcdabcd}, parameter: "0" }
request_internal_valid:
- { ref_parameter: {src: hda, id: 123}, parameter: 0 }
request_internal_invalid:
- { ref_parameter: {src: hda, id: 123}, parameter: "0" }

cwl_int:
request_valid:
- parameter: 5
Expand Down

0 comments on commit 2f19d2c

Please sign in to comment.