Skip to content

Commit 2f19d2c

Browse files
committed
Work toward data column support in tool parameter meta models.
1 parent cb3ec1f commit 2f19d2c

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

lib/galaxy/tool_util/parameters/factory.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
CwlStringParameterModel,
3030
CwlUnionParameterModel,
3131
DataCollectionParameterModel,
32+
DataColumnParameterModel,
3233
DataParameterModel,
3334
DrillDownParameterModel,
3435
FloatParameterModel,
@@ -159,6 +160,10 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT:
159160
hierarchy=hierarchy,
160161
options=static_options,
161162
)
163+
elif param_type == "data_column":
164+
return DataColumnParameterModel(
165+
name=input_source.parse_name(),
166+
)
162167
else:
163168
raise Exception(f"Unknown Galaxy parameter type {param_type}")
164169
elif input_type == "conditional":

lib/galaxy/tool_util/parameters/models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,21 @@ def request_requires_value(self) -> bool:
554554
return self.multiple and not self.optional
555555

556556

557+
class DataColumnParameterModel(BaseGalaxyToolParameterModelDefinition):
558+
parameter_type: Literal["gx_data_column"] = "gx_data_column"
559+
560+
@property
561+
def py_type(self) -> Type:
562+
return StrictInt
563+
564+
def pydantic_template(self, state_representation: StateRepresentationT) -> DynamicModelInformation:
565+
return dynamic_model_information_from_py_type(self, self.py_type)
566+
567+
@property
568+
def request_requires_value(self) -> bool:
569+
return False
570+
571+
557572
DiscriminatorType = Union[bool, str]
558573

559574

@@ -883,6 +898,7 @@ def request_requires_value(self) -> bool:
883898
SelectParameterModel,
884899
DataParameterModel,
885900
DataCollectionParameterModel,
901+
DataColumnParameterModel,
886902
DirectoryUriParameterModel,
887903
RulesParameterModel,
888904
DrillDownParameterModel,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<tool id="gx_data_column" name="gx_data_column" version="1.0.0">
2+
<macros>
3+
<import>macros.xml</import>
4+
</macros>
5+
<command><![CDATA[
6+
echo 'parameter: $parameter' >> '$output'
7+
]]></command>
8+
<inputs>
9+
<param name="ref_parameter" type="data" format="tabular" />
10+
<param name="parameter" type="data_column" data_ref="ref_parameter" multiple="true" />
11+
</inputs>
12+
<expand macro="simple_text_output" />
13+
<tests>
14+
<test>
15+
<param name="ref_parameter" value="2.tabular" />
16+
<param name="parameter" value="1" />
17+
<expand macro="assert_output">
18+
<has_line line="parameter: 1"/>
19+
</expand>
20+
</test>
21+
<test>
22+
<param name="ref_parameter" value="2.tabular" />
23+
<param name="parameter" value="2" />
24+
<expand macro="assert_output">
25+
<has_line line="parameter: 2"/>
26+
</expand>
27+
</test>
28+
<!-- these parameters are implicitly optional -->
29+
<test>
30+
<param name="ref_parameter" value="2.tabular" />
31+
<expand macro="assert_output">
32+
<has_line line="parameter: 1"/>
33+
</expand>
34+
</test>
35+
</tests>
36+
</tool>

test/unit/tool_util/parameter_specification.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,16 @@ gx_drill_down_exact:
631631
- parameter: c
632632
- parameter: {}
633633

634+
gx_data_column:
635+
request_valid:
636+
- { ref_parameter: {src: hda, id: abcdabcd}, parameter: 0 }
637+
request_invalid:
638+
- { ref_parameter: {src: hda, id: abcdabcd}, parameter: "0" }
639+
request_internal_valid:
640+
- { ref_parameter: {src: hda, id: 123}, parameter: 0 }
641+
request_internal_invalid:
642+
- { ref_parameter: {src: hda, id: 123}, parameter: "0" }
643+
634644
cwl_int:
635645
request_valid:
636646
- parameter: 5

0 commit comments

Comments
 (0)