galaxyproject / galaxy

Data intensive science for everyone.
https://galaxyproject.org
Other
1.37k stars 992 forks source link

Mandatory parameters should allways allow to set no default value in the tool xml #16960

Closed bernt-matthias closed 10 months ago

bernt-matthias commented 10 months ago

Describe the bug

Sometimes it's not possible to set a reasonable default for a tool parameter in the tool XML but users must set a value. This is currently not possible at least for numeric parameters and selects.

Numeric parameters produce an error like the following on tool loading.

galaxy.tool_util.toolbox.base ERROR 2023-11-01 21:36:19,551 [pN:main,p:3706683,tN:MainThread] Error reading tool from path: /home/berntm/projects/tools-iuc/tools/hmmer3/hmmsearch.xml
Traceback (most recent call last):
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tool_util/toolbox/base.py", line 865, in _load_tool_tag_set
    tool = self.load_tool(concrete_path, use_cached=False, tool_cache_data_dir=tool_cache_data_dir)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tool_util/toolbox/base.py", line 1092, in load_tool
    tool = self.create_tool(
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 530, in create_tool
    return self._create_tool_from_source(tool_source, config_file=config_file, **kwds)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 546, in _create_tool_from_source
    return create_tool_from_source(self.app, tool_source, **kwds)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 340, in create_tool_from_source
    tool = ToolClass(config_file, tool_source, app, **kwds)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 802, in __init__
    raise e
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 799, in __init__
    self.parse(tool_source, guid=guid, dynamic=dynamic)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 1123, in parse
    self.parse_inputs(self.tool_source)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 1414, in parse_inputs
    inputs = self.parse_input_elem(page_source, enctypes)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 1559, in parse_input_elem
    case.inputs = self.parse_input_elem(case_inputs_source, enctypes, context)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 1609, in parse_input_elem
    param = self.parse_param_elem(input_source, enctypes, context)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/__init__.py", line 1622, in parse_param_elem
    param = ToolParameter.build(self, input_source)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/parameters/basic.py", line 319, in build
    return parameter_types[param_type](tool, input_source)
  File "/tmp/tmpdrabum4r/galaxy-dev/lib/galaxy/tools/parameters/basic.py", line 506, in __init__
    raise ParameterValueError("the attribute 'value' must be set for non optional parameters", self.name, None)

Galaxy Version and/or server at which you observed the bug Galaxy Version: 23.1

Expected behavior

value attribute can be omitted for tool definition user should not be able to submit the tool if no value is set.

nsoranzo commented 10 months ago

The workaround is to use value="" in the XML param. It is true though that is a bit annoying and misleading that you cannot leave the attribute out.

bernt-matthias commented 10 months ago

Thanks for the hint. Sounds like this workaround could be implemented in the Galaxy code pretty easily (usually there are horrible side effects when I think like this). What do you think? Maybe a profile version?

nsoranzo commented 10 months ago

I have a patch, working on tests now. No need to have profile changes.

nsoranzo commented 10 months ago

Fixed in #16966 .