-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any Sequencer implements #399
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
jinchihe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: Is there a limit for how many tasks the
Any Sequencer
can handle?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No limitation for task numbers. Thanks.