-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK/Compiler - Invoke the op_transformers as early as possible (#1464)
* Add reproducible test case * Invoke the op_transformers as early as possible
- Loading branch information
1 parent
f8b0638
commit 381083a
Showing
4 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Callable | ||
|
||
import kfp.dsl as dsl | ||
|
||
def add_common_labels(param): | ||
|
||
def _add_common_labels(op: dsl.ContainerOp) -> dsl.ContainerOp: | ||
return op.add_pod_label('param', param) | ||
|
||
return _add_common_labels | ||
|
||
@dsl.pipeline( | ||
name="Parameters in Op transformation functions", | ||
description="Test that parameters used in Op transformation functions as pod labels " | ||
"would be correcly identified and set as arguments in he generated yaml" | ||
) | ||
def param_substitutions(param = dsl.PipelineParam(name='param')): | ||
dsl.get_pipeline_conf().op_transformers.append(add_common_labels(param)) | ||
|
||
op = dsl.ContainerOp( | ||
name="cop", | ||
image="image", | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
import kfp.compiler as compiler | ||
compiler.Compiler().compile(param_substitutions, __file__ + '.yaml') |
40 changes: 40 additions & 0 deletions
40
sdk/python/tests/compiler/testdata/param_op_transform.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: parameters-in-op-transformation-functions- | ||
spec: | ||
arguments: | ||
parameters: | ||
- name: param | ||
entrypoint: parameters-in-op-transformation-functions | ||
serviceAccountName: pipeline-runner | ||
templates: | ||
- container: | ||
image: image | ||
inputs: | ||
parameters: | ||
- name: param | ||
metadata: | ||
labels: | ||
param: '{{inputs.parameters.param}}' | ||
name: cop | ||
outputs: | ||
artifacts: | ||
- name: mlpipeline-ui-metadata | ||
optional: true | ||
path: /mlpipeline-ui-metadata.json | ||
- name: mlpipeline-metrics | ||
optional: true | ||
path: /mlpipeline-metrics.json | ||
- dag: | ||
tasks: | ||
- arguments: | ||
parameters: | ||
- name: param | ||
value: '{{inputs.parameters.param}}' | ||
name: cop | ||
template: cop | ||
inputs: | ||
parameters: | ||
- name: param | ||
name: parameters-in-op-transformation-functions |