diff --git a/lib/galaxy/workflow/modules.py b/lib/galaxy/workflow/modules.py index 22d469fd8c80..bf7fffae9d90 100644 --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -125,7 +125,7 @@ # ones. RUNTIME_POST_JOB_ACTIONS_KEY = "__POST_JOB_ACTIONS__" -INPUT_PARAMETER_TYPES = Literal["text", "integer", "float", "boolean", "color"] +INPUT_PARAMETER_TYPES = Literal["text", "integer", "float", "boolean", "color", "directory_uri"] POSSIBLE_PARAMETER_TYPES: Tuple[INPUT_PARAMETER_TYPES] = get_args(INPUT_PARAMETER_TYPES) @@ -1210,6 +1210,7 @@ def get_inputs(self): {"value": "float", "label": "Float"}, {"value": "boolean", "label": "Boolean (True or False)"}, {"value": "color", "label": "Color"}, + {"value": "directory_uri", "label": "Directory URI"}, ] input_parameter_type = SelectToolParameter(None, select_source) # encode following loop in description above instead @@ -1269,17 +1270,7 @@ def get_inputs(self): optional_cases = [when_true, when_false] optional_cond.cases = optional_cases - if param_type == "text": - - specify_multiple_source = dict( - name="multiple", - label="Allow multiple selection", - help="Only applies when connected to multi-select parameter(s)", - type="boolean", - ) - - specify_multiple = BooleanToolParameter(None, specify_multiple_source) - + def regex_validator_definition(): add_validators_repeat = Repeat("validators") add_validators_repeat.title = "Add validator to restrict valid input" add_validators_repeat.min = 0 @@ -1306,10 +1297,23 @@ def get_inputs(self): ), } + return add_validators_repeat + + if param_type == "text": + + specify_multiple_source = dict( + name="multiple", + label="Allow multiple selection", + help="Only applies when connected to multi-select parameter(s)", + type="boolean", + ) + + specify_multiple = BooleanToolParameter(None, specify_multiple_source) + # Insert multiple option as first option, which is determined by dictionary insert order when_this_type.inputs = { "multiple": specify_multiple, - "validators": add_validators_repeat, + "validators": regex_validator_definition(), **when_this_type.inputs, } @@ -1427,6 +1431,8 @@ def get_inputs(self): "label": "Set a maximum value for this input", }, ) + if param_type == "directory_uri": + when_this_type.inputs["validators"] = regex_validator_definition() cases.append(when_this_type) @@ -1499,7 +1505,7 @@ def get_runtime_inputs(self, step, connections: Optional[Iterable[WorkflowStepCo parameter_type = parameter_def["parameter_type"] optional = parameter_def["optional"] default_value = parameter_def.get("default", self.default_default_value) - if parameter_type not in ["text", "boolean", "integer", "float", "color"]: + if parameter_type not in ["text", "boolean", "integer", "float", "color", "directory_uri"]: raise ValueError("Invalid parameter type for workflow parameters encountered.") # Optional parameters for tool input source definition. @@ -1610,7 +1616,7 @@ def execute( input_param = self.get_runtime_inputs(self)["input"] # TODO: raise DelayedWorkflowEvaluation if replacement not ready ? Need test try: - input_param.validate(input_value) + input_param.validate(input_value, trans) except ValueError as e: raise FailWorkflowEvaluation( why=InvocationFailureWorkflowParameterInvalid( diff --git a/lib/galaxy/workflow/run_request.py b/lib/galaxy/workflow/run_request.py index a6ca78e3d28c..baeb5492dd6d 100644 --- a/lib/galaxy/workflow/run_request.py +++ b/lib/galaxy/workflow/run_request.py @@ -379,7 +379,7 @@ def build_workflow_run_configs( module_injector.inject(step) input_param = step.module.get_runtime_inputs(step.module)["input"] try: - input_param.validate(input_dict) + input_param.validate(input_dict, trans=trans) except ParameterValueError as e: raise exceptions.RequestParameterInvalidException( f"{step.label or step.order_index + 1}: {e.message_suffix}" diff --git a/lib/galaxy/workflow/workflow_parameter_input_definitions.py b/lib/galaxy/workflow/workflow_parameter_input_definitions.py index 2b31e793e40e..8cb3bc110b5b 100644 --- a/lib/galaxy/workflow/workflow_parameter_input_definitions.py +++ b/lib/galaxy/workflow/workflow_parameter_input_definitions.py @@ -7,12 +7,13 @@ from galaxy.tools.parameters.basic import ( BooleanToolParameter, ColorToolParameter, + DirectoryUriToolParameter, FloatToolParameter, IntegerToolParameter, TextToolParameter, ) -param_types = Literal["text", "integer", "float", "color", "boolean"] +param_types = Literal["text", "integer", "float", "color", "boolean", "directory_uri"] default_source_type = Dict[str, Union[int, float, bool, str]] tool_param_type = Union[ TextToolParameter, @@ -20,6 +21,7 @@ FloatToolParameter, BooleanToolParameter, ColorToolParameter, + DirectoryUriToolParameter, ] @@ -36,6 +38,7 @@ def get_default_parameter(param_type: param_types) -> tool_param_type: FloatToolParameter, BooleanToolParameter, ColorToolParameter, + DirectoryUriToolParameter, ] = TextToolParameter(None, default_source) elif param_type == "integer": input_default_value = IntegerToolParameter(None, default_source) @@ -45,4 +48,6 @@ def get_default_parameter(param_type: param_types) -> tool_param_type: input_default_value = BooleanToolParameter(None, default_source) elif param_type == "color": input_default_value = ColorToolParameter(None, default_source) + elif param_type == "directory_uri": + input_default_value = DirectoryUriToolParameter(None, default_source) return input_default_value