From 18fb12b6f0b85049802f67aa1f2a67206531a796 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 19 Dec 2019 17:52:01 +0100 Subject: [PATCH] Fix optional integer/float comparisons Neither of them can be cast to int/float respectively. Fixes test 3 in bowtie2, which errors with: ``` 2019-12-19 17:11:34,022 ERROR [galaxy.jobs.runners] (12) Failure preparing job Traceback (most recent call last): File "/Users/mvandenb/src/galaxy/lib/galaxy/util/__init__.py", line 1039, in unicodify value = text_type(value) File "/Users/mvandenb/src/galaxy/.venv/lib/python3.6/site-packages/Cheetah/Template.py", line 1053, in __unicode__ return getattr(self, mainMethName)() File "cheetah_DynamicallyCompiledCheetahTemplate_1576771894_0091798_17143.py", line 680, in respond File "/Users/mvandenb/src/galaxy/lib/galaxy/tools/wrappers.py", line 94, in __ne__ return not self == other File "/Users/mvandenb/src/galaxy/lib/galaxy/tools/wrappers.py", line 91, in __eq__ return self._get_cast_value(other) == other File "/Users/mvandenb/src/galaxy/lib/galaxy/tools/wrappers.py", line 88, in _get_cast_value return cast.get(self.input.type, str)(self) File "/Users/mvandenb/src/galaxy/lib/galaxy/tools/wrappers.py", line 117, in __int__ return int(float(self)) File "/Users/mvandenb/src/galaxy/lib/galaxy/tools/wrappers.py", line 120, in __float__ return float(str(self)) ValueError: could not convert string to float: ``` --- lib/galaxy/tools/wrappers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/tools/wrappers.py b/lib/galaxy/tools/wrappers.py index a7425d50472..89776480080 100644 --- a/lib/galaxy/tools/wrappers.py +++ b/lib/galaxy/tools/wrappers.py @@ -83,7 +83,7 @@ class InputValueWrapper(ToolParameterValueWrapper): if self.input.type == 'boolean' and isinstance(other, string_types): return str(self) # For backward compatibility, allow `$wrapper != ""` for optional non-text param - if self.input.optional and self.value is None and isinstance(other, string_types): + if self.input.optional and self.value is None and self.input.type != 'boolean': return str(self) cast = { 'text': str,