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

Add unit tests pipelineparam #975

Merged
merged 8 commits into from
Mar 19, 2019
Next Next commit
fix bug: op_to_template resolve the raw arguments by mapping to the a…
…rgument_inputs but the argument_inputs lost the type information
  • Loading branch information
gaoning777 committed Mar 15, 2019
commit 7a1eddd893fb181c243c58bd37929af3d8a6b4b6
10 changes: 6 additions & 4 deletions sdk/python/kfp/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ def _process_args(self, raw_args, argument_inputs):
matches += _match_serialized_pipelineparam(str(processed_args[i]))
unsanitized_argument_inputs = {}
for x in list(set(matches)):
sanitized_str = str(dsl.PipelineParam(K8sHelper.sanitize_k8s_name(x[1]), K8sHelper.sanitize_k8s_name(x[0]), x[2]))
unsanitized_argument_inputs[sanitized_str] = str(dsl.PipelineParam(x[1], x[0], x[2]))

if len(x) == 3 or (len(x) == 4 and x[3] == ''):
sanitized_str = str(dsl.PipelineParam(K8sHelper.sanitize_k8s_name(x[1]), K8sHelper.sanitize_k8s_name(x[0]), x[2]))
unsanitized_argument_inputs[sanitized_str] = str(dsl.PipelineParam(x[1], x[0], x[2]))
elif len(x) == 4:
sanitized_str = str(dsl.PipelineParam(K8sHelper.sanitize_k8s_name(x[1]), K8sHelper.sanitize_k8s_name(x[0]), x[2], TypeMeta.from_dict_or_str(x[3])))
unsanitized_argument_inputs[sanitized_str] = str(dsl.PipelineParam(x[1], x[0], x[2], TypeMeta.from_dict_or_str(x[3])))
if argument_inputs:
for param in argument_inputs:
if str(param) in unsanitized_argument_inputs:
Expand Down Expand Up @@ -257,7 +260,6 @@ def _build_conventional_artifact(name, path):
}
},
}

processed_arguments = self._process_args(op.arguments, op.argument_inputs)
processed_command = self._process_args(op.command, op.argument_inputs)

Expand Down
3 changes: 3 additions & 0 deletions sdk/python/kfp/dsl/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def to_dict_or_str(self):
@staticmethod
def from_dict_or_str(json):
type_meta = TypeMeta()
if isinstance(json, str) and '{' in json:
import ast
json = ast.literal_eval(json)
if isinstance(json, dict):
if not _check_valid_type_dict(json):
raise ValueError(json + ' is not a valid type string')
Expand Down
8 changes: 7 additions & 1 deletion sdk/python/kfp/dsl/_pipeline_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ def _extract_pipelineparams(payloads: str or list[str]):
matches = []
for payload in payloads:
matches += _match_serialized_pipelineparam(payload)
return [PipelineParam(x[1], x[0], x[2]) for x in list(set(matches))]
pipeline_params = []
for x in list(set(matches)):
if len(x) == 3 or (len(x) == 4 and x[3] == ''):
pipeline_params.append(PipelineParam(x[1], x[0], x[2]))
elif len(x) == 4:
pipeline_params.append(PipelineParam(x[1], x[0], x[2], TypeMeta.from_dict_or_str(x[3])))
return pipeline_params

class PipelineParam(object):
"""Representing a future value that is passed between pipeline components.
Expand Down