forked from opendatahub-io/data-science-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to generate custom task with custom task cr (kubeflow#593)
- Loading branch information
Showing
8 changed files
with
166 additions
and
6 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
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,51 @@ | ||
# Copyright 2021 kubeflow.org | ||
# | ||
# 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 dsl | ||
|
||
MY_CUSTOM_TASK_IMAGE_NAME = "veryunique/image:latest" | ||
from kfp_tekton.tekton import TEKTON_CUSTOM_TASK_IMAGES | ||
TEKTON_CUSTOM_TASK_IMAGES = TEKTON_CUSTOM_TASK_IMAGES.append(MY_CUSTOM_TASK_IMAGE_NAME) | ||
|
||
|
||
def getCustomOp(): | ||
CustomOp = dsl.ContainerOp( | ||
name="any-name", | ||
image=MY_CUSTOM_TASK_IMAGE_NAME, | ||
command=["any", "command"], | ||
arguments=["--apiVersion", "custom_task_api_version", | ||
"--kind", "custom_task_kind", | ||
"--name", "custom_task_name", | ||
"--taskSpec", {"raw": "raw"}, | ||
"--other_custom_task_argument_keys", "args"], | ||
file_outputs={"other_custom_task_argument_keys": '/anypath'} | ||
) | ||
# Annotation to tell the Argo controller that this CustomOp is for specific Tekton runtime only. | ||
CustomOp.add_pod_annotation("valid_container", "false") | ||
return CustomOp | ||
|
||
|
||
@dsl.pipeline( | ||
name='Tekton custom task on Kubeflow Pipeline', | ||
description='Shows how to use Tekton custom task with custom spec on KFP' | ||
) | ||
def custom_task_pipeline(): | ||
test = getCustomOp() | ||
test2 = getCustomOp().after(test) | ||
|
||
|
||
if __name__ == '__main__': | ||
from kfp_tekton.compiler import TektonCompiler | ||
TektonCompiler().compile(custom_task_pipeline, __file__.replace('.py', '.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,51 @@ | ||
# Copyright 2021 kubeflow.org | ||
# | ||
# 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. | ||
|
||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
annotations: | ||
pipelines.kubeflow.org/pipeline_spec: '{"description": "Shows how to use Tekton | ||
custom task with custom spec on KFP", "name": "Tekton custom task on Kubeflow | ||
Pipeline"}' | ||
sidecar.istio.io/inject: 'false' | ||
tekton.dev/artifact_bucket: mlpipeline | ||
tekton.dev/artifact_endpoint: minio-service.kubeflow:9000 | ||
tekton.dev/artifact_endpoint_scheme: http:// | ||
tekton.dev/artifact_items: '{}' | ||
tekton.dev/input_artifacts: '{}' | ||
tekton.dev/output_artifacts: '{}' | ||
name: tekton-custom-task-on-kubeflow-pipeline | ||
spec: | ||
pipelineSpec: | ||
tasks: | ||
- name: any-name | ||
params: | ||
- name: other_custom_task_argument_keys | ||
value: args | ||
taskRef: | ||
apiVersion: custom_task_api_version | ||
kind: custom_task_kind | ||
name: custom_task_name | ||
- name: any-name-2 | ||
params: | ||
- name: other_custom_task_argument_keys | ||
value: args | ||
runAfter: | ||
- any-name | ||
taskRef: | ||
apiVersion: custom_task_api_version | ||
kind: custom_task_kind | ||
name: custom_task_name | ||
timeout: 0s |
20 changes: 20 additions & 0 deletions
20
sdk/python/tests/compiler/testdata/custom_task_spec_customtask_cr1.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,20 @@ | ||
# Copyright 2021 kubeflow.org | ||
# | ||
# 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. | ||
|
||
apiVersion: custom_task_api_version | ||
kind: custom_task_kind | ||
metadata: | ||
name: custom_task_name | ||
spec: | ||
raw: raw |
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