Skip to content

Commit

Permalink
SDK - Skip attributes with missing values during PipelineMeta seriali…
Browse files Browse the repository at this point in the history
…zation
  • Loading branch information
Ark-kun committed Jun 5, 2019
1 parent 7e29b43 commit a64ca7a
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions sdk/python/kfp/dsl/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ def __init__(self,
self.default = default

def to_dict(self):
return {'name': self.name,
'description': self.description,
'type': self.param_type.to_dict_or_str(),
'default': self.default}
result = {}
if self.name:
result['name'] = self.name
if self.description:
result['description'] = self.description
if self.param_type:
result['type'] = self.param_type.to_dict_or_str()
if self.default:
result['default'] = self.default
return result

class ComponentMeta(BaseMeta):
def __init__(
Expand All @@ -112,11 +118,16 @@ def __init__(
self.outputs = [] if outputs is None else outputs

def to_dict(self):
return {'name': self.name,
'description': self.description,
'inputs': [ input.to_dict() for input in self.inputs ],
'outputs': [ output.to_dict() for output in self.outputs ]
}
result = {}
if self.name:
result['name'] = self.name
if self.description:
result['description'] = self.description
if self.inputs:
result['inputs'] = [input.to_dict() for input in self.inputs]
if self.outputs:
result['outputs'] = [output.to_dict() for output in self.outputs]
return result

# Add a pipeline level metadata calss here.
# If one day we combine the component and pipeline yaml, ComponentMeta and PipelineMeta will become one, too.
Expand All @@ -132,10 +143,14 @@ def __init__(
self.inputs = [] if inputs is None else inputs

def to_dict(self):
return {'name': self.name,
'description': self.description,
'inputs': [ input.to_dict() for input in self.inputs ]
}
result = {}
if self.name:
result['name'] = self.name
if self.description:
result['description'] = self.description
if self.inputs:
result['inputs'] = [input.to_dict() for input in self.inputs]
return result

def _annotation_to_typemeta(annotation):
'''_annotation_to_type_meta converts an annotation to an instance of TypeMeta
Expand Down

0 comments on commit a64ca7a

Please sign in to comment.