-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
3,410 additions
and
25 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,82 @@ | ||
# Copyright 2020 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. | ||
|
||
import uuid | ||
from typing import List | ||
from kfp import dsl | ||
|
||
from kfp_tekton.compiler._k8s_helper import sanitize_k8s_name | ||
|
||
|
||
def after_any(container_ops: List[dsl.ContainerOp]): | ||
''' | ||
The function add a flag for any condition handler. | ||
''' | ||
tasks_list = [] | ||
for cop in container_ops: | ||
cop_name = sanitize_k8s_name(cop.name) | ||
tasks_list.append(cop_name) | ||
task_list_str = ",".join(tasks_list) | ||
|
||
def _after_components(cop): | ||
cop.any_sequencer = {"tasks_list": task_list_str} | ||
return cop | ||
return _after_components | ||
|
||
|
||
def generate_any_sequencer(task_list): | ||
''' | ||
Generate any sequencer task | ||
''' | ||
any_sequencer = { | ||
"name": "any-sequencer-" + str(uuid.uuid4().hex[:5]), | ||
"params": [ | ||
{ | ||
"name": "pipelineRun-namespace", | ||
"value": "$(context.pipelineRun.namespace)" | ||
}, | ||
{ | ||
"name": "pipelineRun-name", | ||
"value": "$(context.pipelineRun.name)" | ||
}, | ||
], | ||
"taskSpec": { | ||
"params": [ | ||
{ | ||
"name": "pipelineRun-namespace" | ||
}, | ||
{ | ||
"name": "pipelineRun-name" | ||
} | ||
], | ||
"steps": [ | ||
{ | ||
"name": "main", | ||
"args": [ | ||
"-namespace", | ||
"$(params.pipelineRun-namespace)", | ||
"-prName", | ||
"$(params.pipelineRun-name)", | ||
"-taskList", | ||
task_list | ||
], | ||
"command": [ | ||
"any-taskrun" | ||
], | ||
"image": "dspipelines/any-sequencer:latest" | ||
} | ||
] | ||
} | ||
} | ||
return any_sequencer |
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,56 @@ | ||
# Copyright 2020 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 | ||
from kfp_tekton.compiler import TektonCompiler | ||
from kfp_tekton.compiler.any_sequencer import after_any | ||
|
||
|
||
@dsl.pipeline( | ||
name="Any Sequencer", | ||
description="Any Sequencer Component Demo", | ||
) | ||
def any_sequence_pipeline( | ||
): | ||
task1 = dsl.ContainerOp( | ||
name="task1", | ||
image="registry.access.redhat.com/ubi8/ubi-minimal", | ||
command=["/bin/bash", "-c"], | ||
arguments=["sleep 15"] | ||
) | ||
|
||
task2 = dsl.ContainerOp( | ||
name="task2", | ||
image="registry.access.redhat.com/ubi8/ubi-minimal", | ||
command=["/bin/bash", "-c"], | ||
arguments=["sleep 200"] | ||
) | ||
|
||
task3 = dsl.ContainerOp( | ||
name="task3", | ||
image="registry.access.redhat.com/ubi8/ubi-minimal", | ||
command=["/bin/bash", "-c"], | ||
arguments=["sleep 300"] | ||
) | ||
|
||
task4 = dsl.ContainerOp( | ||
name="task4", | ||
image="registry.access.redhat.com/ubi8/ubi-minimal", | ||
command=["/bin/bash", "-c"], | ||
arguments=["sleep 30"] | ||
).apply(after_any([task1, task2, task3])) | ||
|
||
|
||
if __name__ == "__main__": | ||
TektonCompiler().compile(any_sequence_pipeline, "any_sequencer" + ".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,80 @@ | ||
# Copyright 2020 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: | ||
name: any-sequencer | ||
annotations: | ||
tekton.dev/output_artifacts: '{}' | ||
tekton.dev/input_artifacts: '{}' | ||
tekton.dev/artifact_bucket: mlpipeline | ||
tekton.dev/artifact_endpoint: minio-service.kubeflow:9000 | ||
tekton.dev/artifact_endpoint_scheme: http:// | ||
tekton.dev/artifact_items: '{"task1": [], "task2": [], "task3": [], "task4": []}' | ||
sidecar.istio.io/inject: "false" | ||
anyConditions: '{"any-sequencer-4b2c9": ["task1", "task2", "task3"]}' | ||
pipelines.kubeflow.org/pipeline_spec: '{"description": "Any Sequencer Component | ||
Demo", "name": "Any Sequencer"}' | ||
spec: | ||
pipelineSpec: | ||
tasks: | ||
- name: task1 | ||
taskSpec: | ||
steps: | ||
- name: main | ||
args: [sleep 15] | ||
command: [/bin/bash, -c] | ||
image: registry.access.redhat.com/ubi8/ubi-minimal | ||
timeout: 0s | ||
- name: task2 | ||
taskSpec: | ||
steps: | ||
- name: main | ||
args: [sleep 200] | ||
command: [/bin/bash, -c] | ||
image: registry.access.redhat.com/ubi8/ubi-minimal | ||
timeout: 0s | ||
- name: task3 | ||
taskSpec: | ||
steps: | ||
- name: main | ||
args: [sleep 300] | ||
command: [/bin/bash, -c] | ||
image: registry.access.redhat.com/ubi8/ubi-minimal | ||
timeout: 0s | ||
- name: task4 | ||
taskSpec: | ||
steps: | ||
- name: main | ||
args: [sleep 30] | ||
command: [/bin/bash, -c] | ||
image: registry.access.redhat.com/ubi8/ubi-minimal | ||
timeout: 0s | ||
runAfter: [any-sequencer-4b2c9] | ||
- name: any-sequencer-4b2c9 | ||
params: | ||
- {name: pipelineRun-namespace, value: $(context.pipelineRun.namespace)} | ||
- {name: pipelineRun-name, value: $(context.pipelineRun.name)} | ||
taskSpec: | ||
params: | ||
- {name: pipelineRun-namespace} | ||
- {name: pipelineRun-name} | ||
steps: | ||
- name: main | ||
args: [-namespace, $(params.pipelineRun-namespace), -prName, $(params.pipelineRun-name), | ||
-taskList, 'task1,task2,task3'] | ||
command: [any-taskrun] | ||
image: dspipelines/any-sequencer:latest | ||
timeout: 0s |
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 @@ | ||
_output |
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,4 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi-minimal | ||
|
||
COPY _output/bin/any-taskrun /usr/local/bin | ||
|
Oops, something went wrong.