Skip to content

Commit

Permalink
fix(sdk) separator param. Part of kubeflow#791 (kubeflow#842)
Browse files Browse the repository at this point in the history
* m: typo in a comment

* remove separator param in loop spec

* update test
  • Loading branch information
Udiknedormin authored Feb 1, 2022
1 parent 0163d4c commit eab7b4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 10 additions & 1 deletion sdk/python/kfp_tekton/compiler/_tekton_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _handle_tekton_custom_task(custom_task: dict, workflow: dict, recursive_task
'type': 'string'
} for sub_param in custom_task[custom_task_key]['loop_sub_args']])

# add loop special filed
# add loop special fields
custom_task_cr['kind'] = 'PipelineLoop'
if custom_task[custom_task_key]['spec'].get('parallelism') is not None:
custom_task_cr['spec']['parallelism'] = custom_task[custom_task_key]['spec']['parallelism']
Expand All @@ -238,6 +238,15 @@ def _handle_tekton_custom_task(custom_task: dict, workflow: dict, recursive_task
custom_task_cr = json.loads(
json.dumps(custom_task_cr).replace(custom_task_param['value'], '$(params.%s)' % custom_task_param['name']))

# remove separator from CR params
if custom_task[custom_task_key].get('separator') is not None:
separator_param = custom_task[custom_task_key]['separator']
custom_task_cr['spec']['pipelineSpec']['params'] = [
param
for param in custom_task_cr['spec']['pipelineSpec']['params']
if param['name'] != separator_param
]

# need to process task parameters to replace out of scope results
# because nested graph cannot refer to task results outside of the sub-pipeline.
custom_task_cr_task_names = [custom_task_cr_task['name'] for custom_task_cr_task in custom_task_cr['spec']['pipelineSpec']['tasks']]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ spec:
params:
- name: loop-item-param-2
type: string
- name: loop-item-param-3
type: string
- name: my_pipe_param
type: string
tasks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ metadata:
"kind": "PipelineLoop", "metadata": {"name": "my-pipeline-for-loop-4"}, "spec":
{"iterateParam": "loop-item-param-2", "iterateParamStringSeparator": "loop-item-param-3",
"pipelineSpec": {"params": [{"name": "loop-item-param-2", "type": "string"},
{"name": "loop-item-param-3", "type": "string"}, {"name": "my_pipe_param", "type":
"string"}], "tasks": [{"name": "my-in-coop1", "params": [{"name": "loop-item-param-2",
"value": "$(params.loop-item-param-2)"}, {"name": "my_pipe_param", "value":
"$(params.my_pipe_param)"}], "taskSpec": {"metadata": {"annotations": {"pipelines.kubeflow.org/component_spec_digest":
{"name": "my_pipe_param", "type": "string"}], "tasks": [{"name": "my-in-coop1",
"params": [{"name": "loop-item-param-2", "value": "$(params.loop-item-param-2)"},
{"name": "my_pipe_param", "value": "$(params.my_pipe_param)"}], "taskSpec":
{"metadata": {"annotations": {"pipelines.kubeflow.org/component_spec_digest":
"{\"name\": \"my-in-coop1\", \"outputs\": [], \"version\": \"my-in-coop1@sha256=42f0c6a60c7e435441b8afaeb382a771a9741fe3aabb203748fdbd72b25f1628\"}",
"tekton.dev/template": ""}, "labels": {"pipelines.kubeflow.org/cache_enabled":
"true", "pipelines.kubeflow.org/generation": "", "pipelines.kubeflow.org/pipelinename":
Expand Down

0 comments on commit eab7b4c

Please sign in to comment.