diff --git a/lib/galaxy/tool_util/parameters/factory.py b/lib/galaxy/tool_util/parameters/factory.py index ea735e7e7026..8e56712be5a6 100644 --- a/lib/galaxy/tool_util/parameters/factory.py +++ b/lib/galaxy/tool_util/parameters/factory.py @@ -170,12 +170,20 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT: options=static_options, ) 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) + optional = input_source.parse_optional() return GroupTagParameterModel( name=input_source.parse_name(), + optional=optional, + multiple=multiple, ) elif param_type == "baseurl": return BaseUrlParameterModel( diff --git a/lib/galaxy/tool_util/parameters/models.py b/lib/galaxy/tool_util/parameters/models.py index 0deffb02ea71..5d5a2266d895 100644 --- a/lib/galaxy/tool_util/parameters/models.py +++ b/lib/galaxy/tool_util/parameters/models.py @@ -603,32 +603,40 @@ 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 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): parameter_type: Literal["gx_group_tag"] = "gx_group_tag" + multiple: bool @property def py_type(self) -> Type: - return StrictStr + py_type: Type = StrictStr + if self.multiple: + py_type = list_type(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 True + return not self.optional class BaseUrlParameterModel(BaseGalaxyToolParameterModelDefinition): diff --git a/lib/tool_shed/webapp/frontend/src/schema/schema.ts b/lib/tool_shed/webapp/frontend/src/schema/schema.ts index 7348aaee7abd..1e8bdfc088be 100644 --- a/lib/tool_shed/webapp/frontend/src/schema/schema.ts +++ b/lib/tool_shed/webapp/frontend/src/schema/schema.ts @@ -1243,6 +1243,8 @@ export interface components { is_dynamic: boolean /** Label */ label?: string | null + /** Multiple */ + multiple: boolean /** Name */ name: string /** @@ -1566,6 +1568,8 @@ export interface components { is_dynamic: boolean /** Label */ label?: string | null + /** Multiple */ + multiple: boolean /** Name */ name: string /** 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/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/functional/tools/parameters/gx_group_tag_multiple.xml b/test/functional/tools/parameters/gx_group_tag_multiple.xml new file mode 100644 index 000000000000..d26bf14b16b7 --- /dev/null +++ b/test/functional/tools/parameters/gx_group_tag_multiple.xml @@ -0,0 +1,39 @@ + + + macros.xml + + '$output' + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/functional/tools/parameters/gx_group_tag_optional.xml b/test/functional/tools/parameters/gx_group_tag_optional.xml new file mode 100644 index 000000000000..9f06c3234f00 --- /dev/null +++ b/test/functional/tools/parameters/gx_group_tag_optional.xml @@ -0,0 +1,38 @@ + + + macros.xml + + '$output' + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/functional/tools/parameters/gx_select_multiple.xml b/test/functional/tools/parameters/gx_select_multiple.xml index 0e32bf9653cf..593b4187fc2e 100644 --- a/test/functional/tools/parameters/gx_select_multiple.xml +++ b/test/functional/tools/parameters/gx_select_multiple.xml @@ -23,5 +23,13 @@ echo '$parameter' >> '$output' + + + + + + + + diff --git a/test/functional/tools/parameters/gx_select_multiple_optional.xml b/test/functional/tools/parameters/gx_select_multiple_optional.xml index 8e42fb8b14af..22ac9259b061 100644 --- a/test/functional/tools/parameters/gx_select_multiple_optional.xml +++ b/test/functional/tools/parameters/gx_select_multiple_optional.xml @@ -23,5 +23,12 @@ echo '$parameter' >> '$output' + + + + + + + diff --git a/test/unit/tool_util/parameter_specification.yml b/test/unit/tool_util/parameter_specification.yml index 79cfeb9d1572..d67587a50cbb 100644 --- a/test/unit/tool_util/parameter_specification.yml +++ b/test/unit/tool_util/parameter_specification.yml @@ -707,11 +707,37 @@ 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: + - { 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' } @@ -726,6 +752,40 @@ gx_group_tag: request_internal_invalid: - { ref_parameter: {src: hdca, id: 123}, parameter: null } +gx_group_tag_optional: + request_valid: + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: 'type:matched' } + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: 'matched' } + - { ref_parameter: { src: hdca, id: abcdabcd} } + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: null } + request_invalid: + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: 7 } + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: true } + request_internal_valid: + - { ref_parameter: {src: hdca, id: 123}, parameter: 'type: matched' } + - { ref_parameter: {src: hdca, id: 123}, parameter: null } + request_internal_invalid: + - { ref_parameter: {src: hdca, id: 123}, parameter: 8 } + + +gx_group_tag_multiple: + request_valid: + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: ['type:matched'] } + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: ['matched'] } + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: ['matched'] } + request_invalid: + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: 'matched' } + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: 7 } + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: true } + - { ref_parameter: { src: hdca, id: abcdabcd}, parameter: null } + - { ref_parameter: { src: hdca, id: abcdabcd} } + request_internal_valid: + - { ref_parameter: {src: hdca, id: 123}, parameter: ['type: matched'] } + request_internal_invalid: + - { ref_parameter: {src: hdca, id: 123}, parameter: 8 } + - { ref_parameter: {src: hdca, id: 123}, parameter: null } + + cwl_int: request_valid: - parameter: 5