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

Fixed the handling of PipelineParam-based default values in extract_metadata #1380

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
12 changes: 12 additions & 0 deletions sdk/python/kfp/dsl/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def _annotation_to_typemeta(annotation):
def _extract_component_metadata(func):
'''Creates component metadata structure instance based on the function signature.'''

# Importing here to prevent circular import failures
#TODO: Change _pipeline_param to stop importing _metadata
from ._pipeline_param import PipelineParam

import inspect
fullargspec = inspect.getfullargspec(func)
annotations = fullargspec.annotations
Expand All @@ -172,6 +176,8 @@ def _extract_component_metadata(func):
for arg in fullargspec.args:
arg_type = TypeMeta()
arg_default = arg_defaults[arg] if arg in arg_defaults else None
if isinstance(arg_default, PipelineParam):
arg_default = arg_default.value
if arg in annotations:
arg_type = _annotation_to_typemeta(annotations[arg])
inputs.append(ParameterMeta(name=arg, description='', param_type=arg_type, default=arg_default))
Expand Down Expand Up @@ -199,6 +205,10 @@ def _extract_component_metadata(func):
def _extract_pipeline_metadata(func):
'''Creates pipeline metadata structure instance based on the function signature.'''

# Importing here to prevent circular import failures
#TODO: Change _pipeline_param to stop importing _metadata
Ark-kun marked this conversation as resolved.
Show resolved Hide resolved
from ._pipeline_param import PipelineParam

import inspect
fullargspec = inspect.getfullargspec(func)
args = fullargspec.args
Expand All @@ -219,6 +229,8 @@ def _extract_pipeline_metadata(func):
for arg in args:
arg_type = TypeMeta()
arg_default = arg_defaults[arg] if arg in arg_defaults else None
if isinstance(arg_default, PipelineParam):
arg_default = arg_default.value
if arg in annotations:
arg_type = _annotation_to_typemeta(annotations[arg])
pipeline_meta.inputs.append(ParameterMeta(name=arg, description='', param_type=arg_type, default=arg_default))
Expand Down