Skip to content

Commit a2af629

Browse files
committed
Fix parameter models for optional color params.
1 parent 8693934 commit a2af629

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

lib/galaxy/tool_util_models/parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,14 +921,14 @@ def validate_color_str_or_connected_value(value) -> str:
921921

922922
def pydantic_template(self, state_representation: StateRepresentationT) -> DynamicModelInformation:
923923
py_type = self.py_type
924-
initialize: Any = ...
924+
requires_value = self.request_requires_value
925+
initialize = ... if requires_value else None
925926
if state_representation == "workflow_step_linked":
926927
py_type = allow_connected_value(py_type)
927928
validators = {
928929
"color_format": field_validator(self.name)(ColorParameterModel.validate_color_str_or_connected_value)
929930
}
930931
elif state_representation == "workflow_step":
931-
initialize = None
932932
validators = {"color_format": field_validator(self.name)(ColorParameterModel.validate_color_str_if_value)}
933933
else:
934934
validators = {"color_format": field_validator(self.name)(ColorParameterModel.validate_color_str)}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<tool id="gx_color_optional" name="gx_color_optional" version="1.0.0">
2+
<command>
3+
echo "$parameter" > $out_file1;
4+
</command>
5+
<inputs>
6+
<param name="parameter" type="color" value="#aabbcc" optional="true" />
7+
</inputs>
8+
<outputs>
9+
<data name="out_file1" format="txt" />
10+
</outputs>
11+
<tests>
12+
<test>
13+
<param name="parameter" value="#aaaaaa" />
14+
<output name="out_file1">
15+
<assert_contents>
16+
<has_line line="#aaaaaa" />
17+
</assert_contents>
18+
</output>
19+
</test>
20+
<test>
21+
<output name="out_file1">
22+
<assert_contents>
23+
<has_line line="#aabbcc" />
24+
</assert_contents>
25+
</output>
26+
</test>
27+
</tests>
28+
</tool>

0 commit comments

Comments
 (0)