Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK/Components - convert_object_to_struct now uses __init__ to get field list #733

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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