Skip to content

Commit

Permalink
SDK - Compiler - Fix large data passing (#2173)
Browse files Browse the repository at this point in the history
* SDK - Compiler - Fix large data passing

Stop outputting parameters unless they're consumed as parameters downstream.
This prevents the situaltion when component outputs a big file, but DSL compiler instructs Argo to pick it up as parameter (parameters only hold few kilobytes of data).

As byproduct, this change fixes some minor compiler data passing bugs where some parameters were being passed around, but never consumed (happened with `ResourceOp`, `dsl.Condition` and recursion).

* Replaced ... with `raise AssertionError`

* Fixed small bug

* Removed unused variables

* Fixed names of the mark_upstream_ios_of_* functions

* Fixed detection of parameter output references

* Fixed handling of volumes
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Sep 20, 2019
1 parent 372efe5 commit ef63c65
Show file tree
Hide file tree
Showing 7 changed files with 394 additions and 59 deletions.
387 changes: 387 additions & 0 deletions sdk/python/kfp/compiler/_data_passing_rewriter.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions sdk/python/kfp/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ def create_workflow(self,
dsl_pipeline,
op_transformers)

from ._data_passing_rewriter import fix_big_data_passing
workflow = fix_big_data_passing(workflow)

import json
workflow.setdefault('metadata', {}).setdefault('annotations', {})['pipelines.kubeflow.org/pipeline_spec'] = json.dumps(pipeline_meta.to_dict(), sort_keys=True)

Expand Down
25 changes: 2 additions & 23 deletions sdk/python/tests/compiler/testdata/coin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,13 @@ spec:
parameters:
- name: flip-again-output
value: '{{tasks.flip-again.outputs.parameters.flip-again-output}}'
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
dependencies:
- flip-again
name: condition-2
template: condition-2
when: '"{{tasks.flip-again.outputs.parameters.flip-again-output}}" == "tails"'
- arguments:
parameters:
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
name: flip-again
- name: flip-again
template: flip-again
inputs:
parameters:
- name: flip-output
name: condition-1
outputs:
parameters:
Expand All @@ -57,29 +48,23 @@ spec:
parameters:
- name: flip-again-output
value: '{{inputs.parameters.flip-again-output}}'
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
name: print1
template: print1
inputs:
parameters:
- name: flip-again-output
- name: flip-output
name: condition-2
- dag:
tasks:
- arguments:
parameters:
- name: flip-again-output
value: '{{inputs.parameters.flip-again-output}}'
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
name: print2
template: print2
inputs:
parameters:
- name: flip-again-output
- name: flip-output
name: condition-3
- container:
args:
Expand Down Expand Up @@ -117,11 +102,7 @@ spec:
path: /tmp/output
- dag:
tasks:
- arguments:
parameters:
- name: flip-output
value: '{{tasks.flip.outputs.parameters.flip-output}}'
dependencies:
- dependencies:
- flip
name: condition-1
template: condition-1
Expand All @@ -130,8 +111,6 @@ spec:
parameters:
- name: flip-again-output
value: '{{tasks.condition-1.outputs.parameters.flip-again-output}}'
- name: flip-output
value: '{{tasks.flip.outputs.parameters.flip-output}}'
dependencies:
- condition-1
- flip
Expand Down
4 changes: 0 additions & 4 deletions sdk/python/tests/compiler/testdata/imagepullsecrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ spec:
artifacts:
- name: get-frequent-word
path: /tmp/message.txt
parameters:
- name: get-frequent-word
valueFrom:
path: /tmp/message.txt
- dag:
tasks:
- arguments:
Expand Down
4 changes: 0 additions & 4 deletions sdk/python/tests/compiler/testdata/preemptible_tpu_gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ spec:
artifacts:
- name: flip-output
path: /tmp/output
parameters:
- name: flip-output
valueFrom:
path: /tmp/output
retryStrategy:
limit: 5
tolerations:
Expand Down
4 changes: 0 additions & 4 deletions sdk/python/tests/compiler/testdata/recursive_do_while.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ spec:
artifacts:
- name: flip-2-output
path: /tmp/output
parameters:
- name: flip-2-output
valueFrom:
path: /tmp/output
- container:
args:
- python -c "import random; result = 'heads' if random.randint(0,1) == 0 else
Expand Down
26 changes: 2 additions & 24 deletions sdk/python/tests/compiler/testdata/recursive_while.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ kind: Workflow
metadata:
annotations:
pipelines.kubeflow.org/pipeline_spec: '{"description": "shows how to use dsl.Condition.",
"inputs": [{"default": "12", "name": "maxVal"}],
"name": "pipeline flip coin"}'
"inputs": [{"default": "12", "name": "maxVal"}], "name": "pipeline flip coin"}'
generateName: pipeline-flip-coin-
spec:
arguments:
Expand All @@ -16,20 +15,14 @@ spec:
templates:
- dag:
tasks:
- arguments:
parameters:
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
dependencies:
- dependencies:
- print
name: flip-3
template: flip-3
- arguments:
parameters:
- name: flip-output
value: '{{tasks.flip-3.outputs.parameters.flip-3-output}}'
- name: maxval
value: '{{inputs.parameters.maxval}}'
dependencies:
- flip-3
name: graph-flip-component-1
Expand All @@ -43,7 +36,6 @@ spec:
inputs:
parameters:
- name: flip-output
- name: maxval
name: condition-2
- container:
args:
Expand Down Expand Up @@ -75,10 +67,6 @@ spec:
artifacts:
- name: flip-2-output
path: /tmp/output
parameters:
- name: flip-2-output
valueFrom:
path: /tmp/output
- container:
args:
- python -c "import random; result = 'heads' if random.randint(0,1) == 0 else
Expand All @@ -102,15 +90,12 @@ spec:
parameters:
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
- name: maxval
value: '{{inputs.parameters.maxval}}'
name: condition-2
template: condition-2
when: '"{{inputs.parameters.flip-output}}" == "heads"'
inputs:
parameters:
- name: flip-output
- name: maxval
name: graph-flip-component-1
- dag:
tasks:
Expand All @@ -122,8 +107,6 @@ spec:
parameters:
- name: flip-output
value: '{{tasks.flip.outputs.parameters.flip-output}}'
- name: maxval
value: '{{inputs.parameters.maxval}}'
dependencies:
- flip
- flip-2
Expand All @@ -138,9 +121,6 @@ spec:
- graph-flip-component-1
name: print-2
template: print-2
inputs:
parameters:
- name: maxval
name: pipeline-flip-coin
- container:
command:
Expand All @@ -151,7 +131,6 @@ spec:
parameters:
- name: flip-output
name: print

- container:
command:
- echo
Expand All @@ -161,4 +140,3 @@ spec:
parameters:
- name: flip-output
name: print-2

0 comments on commit ef63c65

Please sign in to comment.