From 250b60b7fe06a339f02d54b3682e5b982726bf0f Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 8 Aug 2024 14:56:32 -0400 Subject: [PATCH] Clarify behavior around unspecified hidden parameters. --- lib/galaxy/tool_util/parameters/factory.py | 2 ++ lib/galaxy/tool_util/parameters/models.py | 3 ++- test/unit/tool_util/parameter_specification.yml | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tool_util/parameters/factory.py b/lib/galaxy/tool_util/parameters/factory.py index e21eb4794631..ea735e7e7026 100644 --- a/lib/galaxy/tool_util/parameters/factory.py +++ b/lib/galaxy/tool_util/parameters/factory.py @@ -108,9 +108,11 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT: ) elif param_type == "hidden": optional = input_source.parse_optional() + value = input_source.get("value") return HiddenParameterModel( name=input_source.parse_name(), optional=optional, + value=value, ) elif param_type == "color": optional = input_source.parse_optional() diff --git a/lib/galaxy/tool_util/parameters/models.py b/lib/galaxy/tool_util/parameters/models.py index 2571ff5c59f5..0deffb02ea71 100644 --- a/lib/galaxy/tool_util/parameters/models.py +++ b/lib/galaxy/tool_util/parameters/models.py @@ -346,6 +346,7 @@ def request_requires_value(self) -> bool: class HiddenParameterModel(BaseGalaxyToolParameterModelDefinition): parameter_type: Literal["gx_hidden"] = "gx_hidden" + value: Optional[str] @property def py_type(self) -> Type: @@ -356,7 +357,7 @@ def pydantic_template(self, state_representation: StateRepresentationT) -> Dynam @property def request_requires_value(self) -> bool: - return not self.optional + return not self.optional and self.value is None def ensure_color_valid(value: Optional[Any]): diff --git a/test/unit/tool_util/parameter_specification.yml b/test/unit/tool_util/parameter_specification.yml index 699d49ec29c7..79cfeb9d1572 100644 --- a/test/unit/tool_util/parameter_specification.yml +++ b/test/unit/tool_util/parameter_specification.yml @@ -202,6 +202,8 @@ gx_hidden: - parameter: moocow - parameter: 'some spaces' - parameter: '' + # it will use a default if value is set in definition and no value supplied (see hidden_param.xml) + - {} request_invalid: - parameter: null - parameter: 5