-
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.
Support GCPC types with function-based component
- Loading branch information
Showing
4 changed files
with
176 additions
and
1 deletion.
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
114 changes: 114 additions & 0 deletions
114
sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_gcpc_types.json
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,114 @@ | ||
{ | ||
"pipelineSpec": { | ||
"components": { | ||
"comp-consumer-op": { | ||
"executorLabel": "exec-consumer-op", | ||
"inputDefinitions": { | ||
"artifacts": { | ||
"model": { | ||
"artifactType": { | ||
"schemaTitle": "google.VertexModel", | ||
"schemaVersion": "0.0.1" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"comp-producer": { | ||
"executorLabel": "exec-producer", | ||
"outputDefinitions": { | ||
"artifacts": { | ||
"model": { | ||
"artifactType": { | ||
"schemaTitle": "google.VertexModel", | ||
"schemaVersion": "0.0.1" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"deploymentSpec": { | ||
"executors": { | ||
"exec-consumer-op": { | ||
"container": { | ||
"args": [ | ||
"--executor_input", | ||
"{{$}}", | ||
"--function_to_execute", | ||
"consumer_op" | ||
], | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"(python3 -m ensurepip || python3 -m ensurepip --user) && (PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location 'kfp==1.8.4' || PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location 'kfp==1.8.4' --user) && \"$0\" \"$@\"", | ||
"sh", | ||
"-ec", | ||
"program_path=$(mktemp -d)\nprintf \"%s\" \"$0\" > \"$program_path/ephemeral_component.py\"\npython3 -m kfp.v2.components.executor_main --component_module_path \"$program_path/ephemeral_component.py\" \"$@\"\n", | ||
"\nfrom kfp.v2.dsl import *\nfrom typing import *\n\ndef consumer_op(model: Input[VertexModel]):\n pass\n\n" | ||
], | ||
"image": "python:3.7" | ||
} | ||
}, | ||
"exec-producer": { | ||
"container": { | ||
"args": [ | ||
"{{$.outputs.artifacts['model'].path}}" | ||
], | ||
"command": [ | ||
"cmd" | ||
], | ||
"image": "dummy" | ||
} | ||
} | ||
} | ||
}, | ||
"pipelineInfo": { | ||
"name": "pipeline-with-gcpc-types" | ||
}, | ||
"root": { | ||
"dag": { | ||
"tasks": { | ||
"consumer-op": { | ||
"cachingOptions": { | ||
"enableCache": true | ||
}, | ||
"componentRef": { | ||
"name": "comp-consumer-op" | ||
}, | ||
"dependentTasks": [ | ||
"producer" | ||
], | ||
"inputs": { | ||
"artifacts": { | ||
"model": { | ||
"taskOutputArtifact": { | ||
"outputArtifactKey": "model", | ||
"producerTask": "producer" | ||
} | ||
} | ||
} | ||
}, | ||
"taskInfo": { | ||
"name": "consumer-op" | ||
} | ||
}, | ||
"producer": { | ||
"cachingOptions": { | ||
"enableCache": true | ||
}, | ||
"componentRef": { | ||
"name": "comp-producer" | ||
}, | ||
"taskInfo": { | ||
"name": "producer" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"schemaVersion": "2.0.0", | ||
"sdkVersion": "kfp-1.8.4" | ||
}, | ||
"runtimeConfig": {} | ||
} |
52 changes: 52 additions & 0 deletions
52
sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_gcpc_types.py
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,52 @@ | ||
# Copyright 2021 The Kubeflow Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from kfp import components | ||
from kfp.v2.dsl import component, Input, Output | ||
from kfp.v2 import compiler | ||
from kfp.v2 import dsl | ||
|
||
|
||
class VertexModel(dsl.Artifact): | ||
TYPE_NAME = 'google.VertexModel' | ||
|
||
|
||
producer_op = components.load_component_from_text(""" | ||
name: producer | ||
outputs: | ||
- {name: model, type: google.VertexModel} | ||
implementation: | ||
container: | ||
image: dummy | ||
command: | ||
- cmd | ||
args: | ||
- {outputPath: model} | ||
""") | ||
|
||
|
||
@component | ||
def consumer_op(model: Input[VertexModel]): | ||
pass | ||
|
||
|
||
@dsl.pipeline(name='pipeline-with-gcpc-types') | ||
def my_pipeline(): | ||
consumer_op(model=producer_op().outputs['model']) | ||
|
||
|
||
if __name__ == '__main__': | ||
compiler.Compiler().compile( | ||
pipeline_func=my_pipeline, | ||
package_path=__file__.replace('.py', '.json')) |
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