Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.0] Don't fail if reporting invalid parameter values #18002

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/galaxy/tools/parameters/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,11 @@ def to_dict(self, trans, other_values=None):
return d


def iter_to_string(iterable: typing.Iterable[typing.Any]) -> typing.Generator[str, None, None]:
for item in iterable:
yield str(item)


class SelectToolParameter(ToolParameter):
"""
Parameter that takes on one (or many) or a specific set of values.
Expand Down Expand Up @@ -1041,8 +1046,9 @@ def from_json(self, value, trans, other_values=None, require_legal_value=True):
elif set(value).issubset(set(fallback_values.keys())):
return [fallback_values[v] for v in value]
else:
invalid_options = iter_to_string(set(value) - set(legal_values))
raise ParameterValueError(
f"invalid options ({','.join(set(value) - set(legal_values))!r}) were selected (valid options: {','.join(legal_values)})",
f"invalid options ({','.join(invalid_options)!r}) were selected (valid options: {','.join(iter_to_string(legal_values))})",
self.name,
is_dynamic=self.is_dynamic,
)
Expand All @@ -1066,7 +1072,7 @@ def from_json(self, value, trans, other_values=None, require_legal_value=True):
return value
else:
raise ParameterValueError(
f"an invalid option ({value!r}) was selected (valid options: {','.join(legal_values)})",
f"an invalid option ({value!r}) was selected (valid options: {','.join(iter_to_string(legal_values))})",
self.name,
value,
is_dynamic=self.is_dynamic,
Expand Down
Loading