diff --git a/lib/galaxy/tool_util/parameters/factory.py b/lib/galaxy/tool_util/parameters/factory.py index fc9fef7bdc12..8e56712be5a6 100644 --- a/lib/galaxy/tool_util/parameters/factory.py +++ b/lib/galaxy/tool_util/parameters/factory.py @@ -171,9 +171,11 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT: ) elif param_type == "data_column": multiple = input_source.get_bool("multiple", False) + optional = input_source.parse_optional() return DataColumnParameterModel( name=input_source.parse_name(), multiple=multiple, + optional=optional, ) elif param_type == "group_tag": multiple = input_source.get_bool("multiple", False) diff --git a/lib/galaxy/tool_util/parameters/models.py b/lib/galaxy/tool_util/parameters/models.py index 0a051cf81a24..5d5a2266d895 100644 --- a/lib/galaxy/tool_util/parameters/models.py +++ b/lib/galaxy/tool_util/parameters/models.py @@ -610,14 +610,14 @@ def py_type(self) -> Type: py_type: Type = StrictInt if self.multiple: py_type = list_type(py_type) - return py_type + return optional_if_needed(py_type, self.optional) 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 + return self.multiple and not self.optional class GroupTagParameterModel(BaseGalaxyToolParameterModelDefinition): diff --git a/test/functional/tools/parameters/gx_data_column_optional.xml b/test/functional/tools/parameters/gx_data_column_optional.xml new file mode 100644 index 000000000000..604c2545bdc6 --- /dev/null +++ b/test/functional/tools/parameters/gx_data_column_optional.xml @@ -0,0 +1,28 @@ + + + macros.xml + + > '$output' + ]]> + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unit/tool_util/parameter_specification.yml b/test/unit/tool_util/parameter_specification.yml index d3ae5455b520..d67587a50cbb 100644 --- a/test/unit/tool_util/parameter_specification.yml +++ b/test/unit/tool_util/parameter_specification.yml @@ -707,6 +707,20 @@ gx_data_column: - { ref_parameter: {src: hda, id: abcdabcd}, parameter: 0 } request_invalid: - { ref_parameter: {src: hda, id: abcdabcd}, parameter: "0" } + - { 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" } + +gx_data_column_optional: + request_valid: + - { ref_parameter: {src: hda, id: abcdabcd}, parameter: 0 } + - { ref_parameter: {src: hda, id: abcdabcd} } + - { ref_parameter: {src: hda, id: abcdabcd}, parameter: null } + request_invalid: + - { ref_parameter: {src: hda, id: abcdabcd}, parameter: "0" } + - { ref_parameter: {src: hda, id: abcdabcd}, parameter: [ 0 ] } request_internal_valid: - { ref_parameter: {src: hda, id: 123}, parameter: 0 } request_internal_invalid: