From c18bfa347565dbcaadbcb80e0ab46f44501d3f1d Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 9 Aug 2024 14:54:12 -0400 Subject: [PATCH 1/6] Tool parameter models for optional group tags. --- lib/galaxy/tool_util/parameters/factory.py | 1 + lib/galaxy/tool_util/parameters/models.py | 4 +- .../parameters/gx_group_tag_optional.xml | 38 +++++++++++++++++++ .../tool_util/parameter_specification.yml | 16 ++++++++ 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 test/functional/tools/parameters/gx_group_tag_optional.xml diff --git a/lib/galaxy/tool_util/parameters/factory.py b/lib/galaxy/tool_util/parameters/factory.py index ea735e7e7026..0f20b2d3feb3 100644 --- a/lib/galaxy/tool_util/parameters/factory.py +++ b/lib/galaxy/tool_util/parameters/factory.py @@ -176,6 +176,7 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT: elif param_type == "group_tag": return GroupTagParameterModel( name=input_source.parse_name(), + optional = input_source.parse_optional(), ) 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..f56582c71c76 100644 --- a/lib/galaxy/tool_util/parameters/models.py +++ b/lib/galaxy/tool_util/parameters/models.py @@ -621,14 +621,14 @@ class GroupTagParameterModel(BaseGalaxyToolParameterModelDefinition): @property def py_type(self) -> Type: - return StrictStr + return optional_if_needed(StrictStr, 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/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/unit/tool_util/parameter_specification.yml b/test/unit/tool_util/parameter_specification.yml index 79cfeb9d1572..cd3525b1b3d7 100644 --- a/test/unit/tool_util/parameter_specification.yml +++ b/test/unit/tool_util/parameter_specification.yml @@ -726,6 +726,22 @@ 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 } + + cwl_int: request_valid: - parameter: 5 From 95da14738e4a10977b70806c265815218b4f21b5 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 9 Aug 2024 15:06:26 -0400 Subject: [PATCH 2/6] Parmaeter models for multiple=true group tags. --- lib/galaxy/tool_util/parameters/factory.py | 5 ++- lib/galaxy/tool_util/parameters/models.py | 6 ++- .../parameters/gx_group_tag_multiple.xml | 39 +++++++++++++++++++ .../tool_util/parameter_specification.yml | 18 +++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 test/functional/tools/parameters/gx_group_tag_multiple.xml diff --git a/lib/galaxy/tool_util/parameters/factory.py b/lib/galaxy/tool_util/parameters/factory.py index 0f20b2d3feb3..a65696333c95 100644 --- a/lib/galaxy/tool_util/parameters/factory.py +++ b/lib/galaxy/tool_util/parameters/factory.py @@ -174,9 +174,12 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT: name=input_source.parse_name(), ) 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 = input_source.parse_optional(), + 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 f56582c71c76..a7f8d9f7f927 100644 --- a/lib/galaxy/tool_util/parameters/models.py +++ b/lib/galaxy/tool_util/parameters/models.py @@ -618,10 +618,14 @@ def request_requires_value(self) -> bool: class GroupTagParameterModel(BaseGalaxyToolParameterModelDefinition): parameter_type: Literal["gx_group_tag"] = "gx_group_tag" + multiple: bool @property def py_type(self) -> Type: - return optional_if_needed(StrictStr, self.optional) + 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) 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/unit/tool_util/parameter_specification.yml b/test/unit/tool_util/parameter_specification.yml index cd3525b1b3d7..f3edc494d2f9 100644 --- a/test/unit/tool_util/parameter_specification.yml +++ b/test/unit/tool_util/parameter_specification.yml @@ -742,6 +742,24 @@ gx_group_tag_optional: - { 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 From c6ea4d3dffc5129214e2a0de597069c8fd0ad4db Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 9 Aug 2024 15:15:14 -0400 Subject: [PATCH 3/6] More clarification of empty/multiple/optional select behaviors. --- test/functional/tools/parameters/gx_select_multiple.xml | 8 ++++++++ .../tools/parameters/gx_select_multiple_optional.xml | 7 +++++++ 2 files changed, 15 insertions(+) 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' + + + + + + + From 67dc43f4e1c01e9475b28234a7f6c9401b6cd442 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 9 Aug 2024 15:18:31 -0400 Subject: [PATCH 4/6] 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' } From b919f21c4744644e25e66751f1ceeab3046a9e4f Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 9 Aug 2024 15:30:13 -0400 Subject: [PATCH 5/6] Parameter models for optional data columns. --- lib/galaxy/tool_util/parameters/factory.py | 2 ++ lib/galaxy/tool_util/parameters/models.py | 4 +-- .../parameters/gx_data_column_optional.xml | 28 +++++++++++++++++++ .../tool_util/parameter_specification.yml | 14 ++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/functional/tools/parameters/gx_data_column_optional.xml 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: From 7011a3a94c02662391312e32dbc175845cf96f1a Mon Sep 17 00:00:00 2001 From: John Chilton Date: Sat, 10 Aug 2024 10:29:19 -0400 Subject: [PATCH 6/6] Rebuild ts schema for recent changes. --- lib/tool_shed/webapp/frontend/src/schema/schema.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tool_shed/webapp/frontend/src/schema/schema.ts b/lib/tool_shed/webapp/frontend/src/schema/schema.ts index e12d45fc9996..424f27d88e77 100644 --- a/lib/tool_shed/webapp/frontend/src/schema/schema.ts +++ b/lib/tool_shed/webapp/frontend/src/schema/schema.ts @@ -745,6 +745,8 @@ export interface components { is_dynamic?: boolean /** Label */ label?: string | null + /** Multiple */ + multiple: boolean /** Name */ name: string /** @@ -1068,6 +1070,8 @@ export interface components { is_dynamic?: boolean /** Label */ label?: string | null + /** Multiple */ + multiple: boolean /** Name */ name: string /**