prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Handling of boolean input types
  I have a pipeline that has a boolean parameter:
  
  ```
  def test(
      param: dsl.PipelineParam = dsl.PipelineParam(name='param', value=True, param_type=TypeMeta('bool')),
  ) -> None:
      pass
  ```
  
  When starting a new pipeline via the UI, the input field is a textbox, prefilled with the input string 'True'. Given that the input value is evaluated using `bool(value)`, the only way to start the pipeline with a `False` value is to leave the input textbox empty.
  
  It seems that currently the pipeline does not gracefully handle boolean parameters?
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sdk/python/kfp/components/_data_passing.py`
  Content:
  ```
  1 # Copyright 2019 Google LLC
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #      http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 __all__ = [
  16     'type_to_type_name',
  17     'type_name_to_type',
  18     'type_to_deserializer',
  19     'type_name_to_deserializer',
  20     'type_name_to_serializer',
  21 ]
  22 
  23 
  24 import inspect
  25 from typing import Any, Callable, NamedTuple, Sequence
  26 import warnings
  27 
  28 
  29 Converter = NamedTuple('Converter', [
  30     ('types', Sequence[str]),
  31     ('type_names', Sequence[str]),
  32     ('serializer', Callable[[Any], str]),
  33     ('deserializer_code', str),
  34     ('definitions', str),
  35 ])
  36 
  37 
  38 _converters = [
  39     Converter([str], ['String', 'str'], str, 'str', None),
  40     Converter([int], ['Integer', 'int'], str, 'int', None),
  41     Converter([float], ['Float', 'float'], str, 'float', None),
  42 ]
  43 
  44 
  45 type_to_type_name = {typ: converter.type_names[0] for converter in _converters for typ in converter.types}
  46 type_name_to_type = {type_name: converter.types[0] for converter in _converters for type_name in converter.type_names if converter.types}
  47 type_to_deserializer = {typ: (converter.deserializer_code, converter.definitions) for converter in _converters for typ in converter.types}
  48 type_name_to_deserializer = {type_name: (converter.deserializer_code, converter.definitions) for converter in _converters for type_name in converter.type_names}
  49 type_name_to_serializer = {type_name: converter.serializer for converter in _converters for type_name in converter.type_names}
  50 
  51 
  52 def serialize_value(value, type_name: str) -> str:
  53     '''serialize_value converts the passed value to string based on the serializer associated with the passed type_name'''
  54     if isinstance(value, str):
  55         return value # The value is supposedly already serialized
  56 
  57     if type_name is None:
  58         type_name = type_to_type_name.get(type(value), type(value).__name__)
  59         warnings.warn('Missing type name was inferred as "{}" based on the value "{}".'.format(type_name, str(value)))
  60 
  61     serializer = type_name_to_serializer.get(type_name, None)
  62     if serializer:
  63         try:
  64             return serializer(value)
  65         except Exception as e:
  66             raise ValueError('Failed to serialize the value "{}" of type "{}" to type "{}". Exception: {}'.format(
  67                 str(value),
  68                 str(type(value).__name__),
  69                 str(type_name),
  70                 str(e),
  71             ))
  72 
  73     serialized_value = str(value)
  74     warnings.warn('There are no registered serializers from type "{}" to type "{}", so the value will be serializers as string "{}".'.format(
  75         str(type(value).__name__),
  76         str(type_name),
  77         serialized_value),
  78     )
  79     return serialized_value
  80
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sdk/python/kfp/components/_data_passing.py b/sdk/python/kfp/components/_data_passing.py
  --- a/sdk/python/kfp/components/_data_passing.py
  +++ b/sdk/python/kfp/components/_data_passing.py
  @@ -35,10 +35,20 @@
   ])
   
   
  +def _deserialize_bool(s) -> bool:
  +    from distutils.util import strtobool
  +    return strtobool(s) == 1
  +
  +
  +_bool_deserializer_definitions = inspect.getsource(_deserialize_bool)
  +_bool_deserializer_code = _deserialize_bool.__name__
  +
  +
   _converters = [
       Converter([str], ['String', 'str'], str, 'str', None),
       Converter([int], ['Integer', 'int'], str, 'int', None),
       Converter([float], ['Float', 'float'], str, 'float', None),
  +    Converter([bool], ['Boolean', 'bool'], str, _bool_deserializer_code, _bool_deserializer_definitions),
   ]
  
verification_info: {"golden_diff": "diff --git a/sdk/python/kfp/components/_data_passing.py b/sdk/python/kfp/components/_data_passing.py\n--- a/sdk/python/kfp/components/_data_passing.py\n+++ b/sdk/python/kfp/components/_data_passing.py\n@@ -35,10 +35,20 @@\n ])\n \n \n+def _deserialize_bool(s) -> bool:\n+    from distutils.util import strtobool\n+    return strtobool(s) == 1\n+\n+\n+_bool_deserializer_definitions = inspect.getsource(_deserialize_bool)\n+_bool_deserializer_code = _deserialize_bool.__name__\n+\n+\n _converters = [\n     Converter([str], ['String', 'str'], str, 'str', None),\n     Converter([int], ['Integer', 'int'], str, 'int', None),\n     Converter([float], ['Float', 'float'], str, 'float', None),\n+    Converter([bool], ['Boolean', 'bool'], str, _bool_deserializer_code, _bool_deserializer_definitions),\n ]\n", "issue": "Handling of boolean input types\nI have a pipeline that has a boolean parameter:\r\n\r\n```\r\ndef test(\r\n    param: dsl.PipelineParam = dsl.PipelineParam(name='param', value=True, param_type=TypeMeta('bool')),\r\n) -> None:\r\n    pass\r\n```\r\n\r\nWhen starting a new pipeline via the UI, the input field is a textbox, prefilled with the input string 'True'. Given that the input value is evaluated using `bool(value)`, the only way to start the pipeline with a `False` value is to leave the input textbox empty.\r\n\r\nIt seems that currently the pipeline does not gracefully handle boolean parameters?\n", "before_files": [{"content": "# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n__all__ = [\n    'type_to_type_name',\n    'type_name_to_type',\n    'type_to_deserializer',\n    'type_name_to_deserializer',\n    'type_name_to_serializer',\n]\n\n\nimport inspect\nfrom typing import Any, Callable, NamedTuple, Sequence\nimport warnings\n\n\nConverter = NamedTuple('Converter', [\n    ('types', Sequence[str]),\n    ('type_names', Sequence[str]),\n    ('serializer', Callable[[Any], str]),\n    ('deserializer_code', str),\n    ('definitions', str),\n])\n\n\n_converters = [\n    Converter([str], ['String', 'str'], str, 'str', None),\n    Converter([int], ['Integer', 'int'], str, 'int', None),\n    Converter([float], ['Float', 'float'], str, 'float', None),\n]\n\n\ntype_to_type_name = {typ: converter.type_names[0] for converter in _converters for typ in converter.types}\ntype_name_to_type = {type_name: converter.types[0] for converter in _converters for type_name in converter.type_names if converter.types}\ntype_to_deserializer = {typ: (converter.deserializer_code, converter.definitions) for converter in _converters for typ in converter.types}\ntype_name_to_deserializer = {type_name: (converter.deserializer_code, converter.definitions) for converter in _converters for type_name in converter.type_names}\ntype_name_to_serializer = {type_name: converter.serializer for converter in _converters for type_name in converter.type_names}\n\n\ndef serialize_value(value, type_name: str) -> str:\n    '''serialize_value converts the passed value to string based on the serializer associated with the passed type_name'''\n    if isinstance(value, str):\n        return value # The value is supposedly already serialized\n\n    if type_name is None:\n        type_name = type_to_type_name.get(type(value), type(value).__name__)\n        warnings.warn('Missing type name was inferred as \"{}\" based on the value \"{}\".'.format(type_name, str(value)))\n\n    serializer = type_name_to_serializer.get(type_name, None)\n    if serializer:\n        try:\n            return serializer(value)\n        except Exception as e:\n            raise ValueError('Failed to serialize the value \"{}\" of type \"{}\" to type \"{}\". Exception: {}'.format(\n                str(value),\n                str(type(value).__name__),\n                str(type_name),\n                str(e),\n            ))\n\n    serialized_value = str(value)\n    warnings.warn('There are no registered serializers from type \"{}\" to type \"{}\", so the value will be serializers as string \"{}\".'.format(\n        str(type(value).__name__),\n        str(type_name),\n        serialized_value),\n    )\n    return serialized_value\n", "path": "sdk/python/kfp/components/_data_passing.py"}], "after_files": [{"content": "# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n__all__ = [\n    'type_to_type_name',\n    'type_name_to_type',\n    'type_to_deserializer',\n    'type_name_to_deserializer',\n    'type_name_to_serializer',\n]\n\n\nimport inspect\nfrom typing import Any, Callable, NamedTuple, Sequence\nimport warnings\n\n\nConverter = NamedTuple('Converter', [\n    ('types', Sequence[str]),\n    ('type_names', Sequence[str]),\n    ('serializer', Callable[[Any], str]),\n    ('deserializer_code', str),\n    ('definitions', str),\n])\n\n\ndef _deserialize_bool(s) -> bool:\n    from distutils.util import strtobool\n    return strtobool(s) == 1\n\n\n_bool_deserializer_definitions = inspect.getsource(_deserialize_bool)\n_bool_deserializer_code = _deserialize_bool.__name__\n\n\n_converters = [\n    Converter([str], ['String', 'str'], str, 'str', None),\n    Converter([int], ['Integer', 'int'], str, 'int', None),\n    Converter([float], ['Float', 'float'], str, 'float', None),\n    Converter([bool], ['Boolean', 'bool'], str, _bool_deserializer_code, _bool_deserializer_definitions),\n]\n\n\ntype_to_type_name = {typ: converter.type_names[0] for converter in _converters for typ in converter.types}\ntype_name_to_type = {type_name: converter.types[0] for converter in _converters for type_name in converter.type_names if converter.types}\ntype_to_deserializer = {typ: (converter.deserializer_code, converter.definitions) for converter in _converters for typ in converter.types}\ntype_name_to_deserializer = {type_name: (converter.deserializer_code, converter.definitions) for converter in _converters for type_name in converter.type_names}\ntype_name_to_serializer = {type_name: converter.serializer for converter in _converters for type_name in converter.type_names}\n\n\ndef serialize_value(value, type_name: str) -> str:\n    '''serialize_value converts the passed value to string based on the serializer associated with the passed type_name'''\n    if isinstance(value, str):\n        return value # The value is supposedly already serialized\n\n    if type_name is None:\n        type_name = type_to_type_name.get(type(value), type(value).__name__)\n        warnings.warn('Missing type name was inferred as \"{}\" based on the value \"{}\".'.format(type_name, str(value)))\n\n    serializer = type_name_to_serializer.get(type_name, None)\n    if serializer:\n        try:\n            return serializer(value)\n        except Exception as e:\n            raise ValueError('Failed to serialize the value \"{}\" of type \"{}\" to type \"{}\". Exception: {}'.format(\n                str(value),\n                str(type(value).__name__),\n                str(type_name),\n                str(e),\n            ))\n\n    serialized_value = str(value)\n    warnings.warn('There are no registered serializers from type \"{}\" to type \"{}\", so the value will be serializers as string \"{}\".'.format(\n        str(type(value).__name__),\n        str(type_name),\n        serialized_value),\n    )\n    return serialized_value\n", "path": "sdk/python/kfp/components/_data_passing.py"}]}