From 9eadbe2d0fb6124b7bdfc563dc7600cd1a10828a Mon Sep 17 00:00:00 2001 From: Alexey Volkov Date: Tue, 27 Aug 2019 11:09:36 -0700 Subject: [PATCH] SDK - Veryfying that the serializer returns string This change was prompted by the failure when b64encode was returning bytes instead of str. --- sdk/python/kfp/components/_data_passing.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk/python/kfp/components/_data_passing.py b/sdk/python/kfp/components/_data_passing.py index f777fa94b6a..cc38d7bcf21 100644 --- a/sdk/python/kfp/components/_data_passing.py +++ b/sdk/python/kfp/components/_data_passing.py @@ -96,7 +96,10 @@ def serialize_value(value, type_name: str) -> str: serializer = type_name_to_serializer.get(type_name, None) if serializer: try: - return serializer(value) + serialized_value = serializer(value) + if not isinstance(serialized_value, str): + raise TypeError('Serializer {} returned result of type "{}" instead of string.'.format(serializer, type(serialized_value))) + return serialized_value except Exception as e: raise ValueError('Failed to serialize the value "{}" of type "{}" to type "{}". Exception: {}'.format( str(value),