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

SDK - Persisting all output values #2134

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions sdk/python/kfp/compiler/_op_to_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ def _op_to_template(op: BaseOp):
if isinstance(op, dsl.ContainerOp):
# default output artifacts
output_artifact_paths = OrderedDict(op.output_artifact_paths)
# This should have been as easy as output_artifact_paths.update(op.file_outputs), but the _outputs_to_json function changes the output names and we must do the same here, so that the names are the same
output_artifact_paths.update(sorted(((param.full_name, processed_op.file_outputs[param.name]) for param in processed_op.outputs.values()), key=lambda x: x[0]))

output_artifacts = [
K8sHelper.convert_k8s_obj_to_json(
Expand Down
9 changes: 8 additions & 1 deletion sdk/python/tests/compiler/compiler_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def my_pipeline(msg1, json, kind, msg2='value2'):
]},
'name': 'echo',
'outputs': {
'artifacts': [
{
'name': 'echo-merged',
'path': '/tmp/message.txt',
},
],
'parameters': [
{'name': 'echo-merged',
'valueFrom': {'path': '/tmp/message.txt'}
Expand Down Expand Up @@ -571,7 +577,8 @@ def _test_op_to_template_yaml(self, ops, file_base_name):
compiled_template = compiler._op_to_template._op_to_template(ops)

del compiled_template['name'], expected['name']
del compiled_template['outputs']['parameters'][0]['name'], expected['outputs']['parameters'][0]['name']
for output in compiled_template['outputs'].get('parameters', []) + compiled_template['outputs'].get('artifacts', []) + expected['outputs'].get('parameters', []) + expected['outputs'].get('artifacts', []):
del output['name']
assert compiled_template == expected

def test_tolerations(self):
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ spec:
- name: message
name: get-frequent
outputs:
artifacts:
- name: get-frequent-word
path: /tmp/message.txt
parameters:
- name: get-frequent-word
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/basic_no_decorator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ spec:
- name: message
name: get-frequent
outputs:
artifacts:
- name: get-frequent-word
path: /tmp/message.txt
parameters:
- name: get-frequent-word
valueFrom:
Expand Down
6 changes: 6 additions & 0 deletions sdk/python/tests/compiler/testdata/coin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ spec:
image: python:alpine3.6
name: flip
outputs:
artifacts:
- name: flip-output
path: /tmp/output
parameters:
- name: flip-output
valueFrom:
Expand All @@ -105,6 +108,9 @@ spec:
image: python:alpine3.6
name: flip-again
outputs:
artifacts:
- name: flip-again-output
path: /tmp/output
parameters:
- name: flip-again-output
valueFrom:
Expand Down
6 changes: 6 additions & 0 deletions sdk/python/tests/compiler/testdata/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ spec:
- name: url
name: download
outputs:
artifacts:
- name: download-downloaded
path: /tmp/results.txt
parameters:
- name: download-downloaded
valueFrom:
Expand Down Expand Up @@ -85,6 +88,9 @@ spec:
- name: download-downloaded
name: get-frequent
outputs:
artifacts:
- name: get-frequent-word
path: /tmp/message.txt
parameters:
- name: get-frequent-word
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/default_value.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ spec:
- name: url
name: download
outputs:
artifacts:
- name: download-downloaded
path: /tmp/results.txt
parameters:
- name: download-downloaded
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/imagepullsecrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ spec:
- name: message
name: get-frequent
outputs:
artifacts:
- name: get-frequent-word
path: /tmp/message.txt
parameters:
- name: get-frequent-word
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/pipelineparams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ spec:
- sh
- "-c"
outputs:
artifacts:
- name: download-downloaded
path: "/tmp/results.txt"
parameters:
- name: download-downloaded
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/preemptible_tpu_gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ spec:
nodeSelector:
cloud.google.com/gke-preemptible: 'true'
outputs:
artifacts:
- name: flip-output
path: /tmp/output
parameters:
- name: flip-output
valueFrom:
Expand Down
9 changes: 9 additions & 0 deletions sdk/python/tests/compiler/testdata/recursive_do_while.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ spec:
image: python:alpine3.6
name: flip
outputs:
artifacts:
- name: flip-output
path: /tmp/output
parameters:
- name: flip-output
valueFrom:
Expand All @@ -47,6 +50,9 @@ spec:
image: python:alpine3.6
name: flip-2
outputs:
artifacts:
- name: flip-2-output
path: /tmp/output
parameters:
- name: flip-2-output
valueFrom:
Expand All @@ -61,6 +67,9 @@ spec:
image: python:alpine3.6
name: flip-3
outputs:
artifacts:
- name: flip-3-output
path: /tmp/output
parameters:
- name: flip-3-output
valueFrom:
Expand Down
9 changes: 9 additions & 0 deletions sdk/python/tests/compiler/testdata/recursive_while.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ spec:
image: python:alpine3.6
name: flip
outputs:
artifacts:
- name: flip-output
path: /tmp/output
parameters:
- name: flip-output
valueFrom:
Expand All @@ -69,6 +72,9 @@ spec:
image: python:alpine3.6
name: flip-2
outputs:
artifacts:
- name: flip-2-output
path: /tmp/output
parameters:
- name: flip-2-output
valueFrom:
Expand All @@ -83,6 +89,9 @@ spec:
image: python:alpine3.6
name: flip-3
outputs:
artifacts:
- name: flip-3-output
path: /tmp/output
parameters:
- name: flip-3-output
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/sidecar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ spec:
parameters: []
templates:
- outputs:
artifacts:
- name: download-downloaded
path: "/tmp/results.txt"
parameters:
- name: download-downloaded
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/tolerations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ spec:
parameters: []
templates:
- outputs:
artifacts:
- name: download-downloaded
path: "/tmp/results.txt"
parameters:
- name: download-downloaded
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ spec:
name: gcp-credentials
name: download
outputs:
artifacts:
- name: download-downloaded
path: /tmp/results.txt
parameters:
- name: download-downloaded
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/withparam_global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ spec:
image: python:alpine3.6
name: my-out-cop0
outputs:
artifacts:
- name: my-out-cop0-out
path: /tmp/out.json
parameters:
- name: my-out-cop0-out
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/withparam_global_dict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ spec:
image: python:alpine3.6
name: my-out-cop0
outputs:
artifacts:
- name: my-out-cop0-out
path: /tmp/out.json
parameters:
- name: my-out-cop0-out
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/withparam_output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
image: python:alpine3.6
name: my-out-cop0
outputs:
artifacts:
- name: my-out-cop0-out
path: /tmp/out.json
parameters:
- name: my-out-cop0-out
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/tests/compiler/testdata/withparam_output_dict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
image: python:alpine3.6
name: my-out-cop0
outputs:
artifacts:
- name: my-out-cop0-out
path: /tmp/out.json
parameters:
- name: my-out-cop0-out
valueFrom:
Expand Down