galaxyproject / galaxy

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

Allow setting a default for workflow parameters, without making them optional #16648

Open simonbray opened 1 year ago

simonbray commented 1 year ago

In order to set a default value for a workflow parameter, the Optional boolean has to be set to true:

image

But of course a workflow developer may well want to set a default for a non-optional parameter.

If the workflow user removes the default value for such a parameter and submits the workflow with the input left empty, at some point a tool will fail with an error similar to the following:

Traceback (most recent call last):
  File "/srv/galaxy/server/lib/galaxy/jobs/runners/__init__.py", line 273, in prepare_job
    job_wrapper.prepare()
  File "/srv/galaxy/server/lib/galaxy/jobs/__init__.py", line 1247, in prepare
    tool_evaluator.set_compute_environment(compute_environment, get_special=get_special)
  File "/srv/galaxy/server/lib/galaxy/tools/evaluation.py", line 134, in set_compute_environment
    incoming = self.tool.params_from_strings(incoming, self.app)
  File "/srv/galaxy/server/lib/galaxy/tools/__init__.py", line 2160, in params_from_strings
    return params_from_strings(self.inputs, params, app, ignore_errors)
  File "/srv/galaxy/server/lib/galaxy/tools/parameters/__init__.py", line 292, in params_from_strings
    value = param.value_from_basic(value, app, ignore_errors)
  File "/srv/galaxy/server/lib/galaxy/tools/parameters/basic.py", line 244, in value_from_basic
    return self.to_python(value, app)
  File "/srv/galaxy/server/lib/galaxy/tools/parameters/basic.py", line 544, in to_python
    raise err
  File "/srv/galaxy/server/lib/galaxy/tools/parameters/basic.py", line 538, in to_python
    return float(value)
ValueError: could not convert string to float: ''
mvdbeek commented 1 year ago

This is somewhat related, but for tool parameters: https://github.com/galaxyproject/galaxy/issues/4736

mvdbeek commented 1 year ago

Since I had to have a required value with a default today, one thing you can do now is use the pick_value tool and an optional input, and set the default value when in the pick value tool if the first input is null. That'll fix the traceback situation above.