Skip to content

Commit

Permalink
SDK/Components - convert_object_to_struct now uses __init__ to get fi…
Browse files Browse the repository at this point in the history
…eld list (#733)

This stops serialization of any additional attributes set on an object
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Jan 25, 2019
1 parent 8c4f5de commit edf9b54
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sdk/python/kfp/components/modelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ def convert_object_to_struct(obj, serialized_names: Mapping[str, str] = {}):
'''
signature = inspect.signature(obj.__init__) #Needed for default values
result = {}
for python_name, value in obj.__dict__.items(): #TODO: Should we take the fields from the constructor parameters instead? #TODO: Make it possible to specify the field ordering
for python_name in signature.parameters: #TODO: Make it possible to specify the field ordering regardless of the presence of default values
value = getattr(obj, python_name)
if python_name.startswith('_'):
continue
attr_name = serialized_names.get(python_name, python_name)
Expand Down

0 comments on commit edf9b54

Please sign in to comment.