Skip to content

Commit

Permalink
Allow non-optional integer/float params without value attribute
Browse files Browse the repository at this point in the history
Previously a tool with such an input would fail to load.

Add test tool.
  • Loading branch information
nsoranzo committed Nov 2, 2023
1 parent b3bdf05 commit 1e86672
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lib/galaxy/tools/parameters/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,6 @@ def __init__(self, tool, input_source):
int(self.value)
except ValueError:
raise ParameterValueError("the attribute 'value' must be an integer", self.name)
elif self.value is None and not self.optional:
raise ParameterValueError("the attribute 'value' must be set for non optional parameters", self.name, None)
self.min = input_source.get("min")
self.max = input_source.get("max")
if self.min:
Expand Down Expand Up @@ -511,8 +509,6 @@ def __init__(self, tool, input_source):
float(self.value)
except ValueError:
raise ParameterValueError("the attribute 'value' must be a real number", self.name, self.value)
elif self.value is None and not self.optional:
raise ParameterValueError("the attribute 'value' must be set for non optional parameters", self.name, None)
if self.min:
try:
self.min = float(self.min)
Expand Down
33 changes: 33 additions & 0 deletions test/functional/tools/integer_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<tool id="integer_default" name="Test integer default" version="0.1.0">
<command><![CDATA[
echo ${int($input1) + int($input2) + int($input3)} > '$out_file1'
]]></command>
<inputs>
<param name="input1" type="integer" value="0" label="Integer with default 0" />
<param name="input2" type="integer" value="" label="Integer with default empty string" />
<!-- Not needed any more to have `value=""` when there is no good default -->
<param name="input3" type="integer" label="Integer with no default value" />
</inputs>
<outputs>
<data name="out_file1" format="txt"/>
</outputs>
<tests>
<test>
<param name="input1" value="1" />
<param name="input2" value="2" />
<param name="input3" value="3" />
<output name="out_file1">
<assert_contents>
<has_line line="6" />
</assert_contents>
</output>
</test>
<!-- Test that it fails if a non-optional integer param is not set -->
<test expect_failure="true">
<param name="input1" value="1" />
<param name="input2" value="2" />
</test>
</tests>
<help>
</help>
</tool>
1 change: 1 addition & 0 deletions test/functional/tools/sample_tool_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<tool file="config_vars.xml" />
<tool file="expect_num_outputs.xml" />
<tool file="text_repeat.xml" />
<tool file="integer_default.xml" />

<tool file="multiple_versions_v01.xml" />
<tool file="multiple_versions_v01galaxy6.xml" />
Expand Down

0 comments on commit 1e86672

Please sign in to comment.