Skip to content

Commit

Permalink
SDK - Veryfying that the serializer returns string (#1965)
Browse files Browse the repository at this point in the history
This change was prompted by the failure when b64encode was returning bytes instead of str.
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Aug 27, 2019
1 parent d043d16 commit 3a30b2b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sdk/python/kfp/components/_data_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 3a30b2b

Please sign in to comment.