From 67dc43f4e1c01e9475b28234a7f6c9401b6cd442 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 9 Aug 2024 15:18:31 -0400 Subject: [PATCH] Parameter models for multiple=true data column data parameters. --- lib/galaxy/tool_util/parameters/factory.py | 2 ++ lib/galaxy/tool_util/parameters/models.py | 6 +++- .../data_column_multiple_optional.xml | 28 +++++++++++++++ .../parameters/gx_data_column_multiple.xml | 36 +++++++++++++++++++ .../tool_util/parameter_specification.yml | 12 +++++++ 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 test/functional/tools/parameters/data_column_multiple_optional.xml create mode 100644 test/functional/tools/parameters/gx_data_column_multiple.xml diff --git a/lib/galaxy/tool_util/parameters/factory.py b/lib/galaxy/tool_util/parameters/factory.py index a65696333c95..fc9fef7bdc12 100644 --- a/lib/galaxy/tool_util/parameters/factory.py +++ b/lib/galaxy/tool_util/parameters/factory.py @@ -170,8 +170,10 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT: options=static_options, ) elif param_type == "data_column": + multiple = input_source.get_bool("multiple", False) return DataColumnParameterModel( name=input_source.parse_name(), + multiple=multiple, ) 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 a7f8d9f7f927..0a051cf81a24 100644 --- a/lib/galaxy/tool_util/parameters/models.py +++ b/lib/galaxy/tool_util/parameters/models.py @@ -603,10 +603,14 @@ def any_drill_down_options_selected(options: List[DrillDownOptionsDict]) -> bool class DataColumnParameterModel(BaseGalaxyToolParameterModelDefinition): parameter_type: Literal["gx_data_column"] = "gx_data_column" + multiple: bool @property def py_type(self) -> Type: - return StrictInt + py_type: Type = StrictInt + if self.multiple: + py_type = list_type(py_type) + return py_type def pydantic_template(self, state_representation: StateRepresentationT) -> DynamicModelInformation: return dynamic_model_information_from_py_type(self, self.py_type) diff --git a/test/functional/tools/parameters/data_column_multiple_optional.xml b/test/functional/tools/parameters/data_column_multiple_optional.xml new file mode 100644 index 000000000000..b9bb1fc0639c --- /dev/null +++ b/test/functional/tools/parameters/data_column_multiple_optional.xml @@ -0,0 +1,28 @@ + + + macros.xml + + > '$output' + ]]> + + + + + + + + + + + + + + + + + + + + + diff --git a/test/functional/tools/parameters/gx_data_column_multiple.xml b/test/functional/tools/parameters/gx_data_column_multiple.xml new file mode 100644 index 000000000000..ed37a530d19b --- /dev/null +++ b/test/functional/tools/parameters/gx_data_column_multiple.xml @@ -0,0 +1,36 @@ + + + macros.xml + + > '$output' + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unit/tool_util/parameter_specification.yml b/test/unit/tool_util/parameter_specification.yml index f3edc494d2f9..d3ae5455b520 100644 --- a/test/unit/tool_util/parameter_specification.yml +++ b/test/unit/tool_util/parameter_specification.yml @@ -712,6 +712,18 @@ gx_data_column: request_internal_invalid: - { ref_parameter: {src: hda, id: 123}, parameter: "0" } +gx_data_column_multiple: + request_valid: + - { 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" } + - { ref_parameter: {src: hda, id: 123}, parameter: 0 } + gx_group_tag: request_valid: - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: 'type:matched' }