Skip to content

Commit

Permalink
Add resource op owner reference mapping (kubeflow#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomcli authored Apr 28, 2022
1 parent 8ba08e2 commit 7dd9498
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions sdk/python/kfp_tekton/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,16 @@ def _process_resourceOp(self, task_refs, pipeline):
merge_strategy = op.resource.get('merge_strategy')
success_condition = op.resource.get('successCondition')
failure_condition = op.resource.get('failureCondition')
set_owner_reference = op.resource.get('setOwnerReference')
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != "image"]
if not merge_strategy:
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != 'merge-strategy']
if not success_condition:
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != 'success-condition']
if not failure_condition:
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != "failure-condition"]
if not set_owner_reference:
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != "set-ownerreference"]
for tp in task.get('params', []):
if tp.get('name') == "action" and action:
tp['value'] = action
Expand All @@ -791,6 +794,8 @@ def _process_resourceOp(self, task_refs, pipeline):
tp['value'] = success_condition
if tp.get('name') == "failure-condition" and failure_condition:
tp['value'] = failure_condition
if tp.get('name') == "set-ownerreference" and set_owner_reference:
tp['value'] = set_owner_reference
if tp.get('name') == "output":
output_values = ''
for value in sorted(list(op.attribute_outputs.items()), key=lambda x: x[0]):
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/tests/compiler/testdata/resourceop_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def resourceop_basic():
op = dsl.ResourceOp(
name='test-step',
k8s_resource=json.loads(_CONTAINER_MANIFEST),
action='create'
action='create',
set_owner_reference='true'
# success_condition='status.succeeded > 0',
# failure_condition='status.failed > 0'
)
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/tests/compiler/testdata/resourceop_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
- name: name
valueFrom: '{.metadata.name}'
- name: set-ownerreference
value: "false"
value: "true"
taskSpec:
params:
- description: Action on the resource
Expand Down
2 changes: 0 additions & 2 deletions sdk/python/tests/compiler/testdata/volume_op.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ spec:
valueFrom: '{.metadata.name}'
- name: size
valueFrom: '{.status.capacity.storage}'
- name: set-ownerreference
value: "false"
- name: size
value: $(params.size)
taskSpec:
Expand Down

0 comments on commit 7dd9498

Please sign in to comment.