forked from opendatahub-io/data-science-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support parallelism feature on DSL side (kubeflow#592)
- Loading branch information
Showing
7 changed files
with
224 additions
and
0 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
55 changes: 55 additions & 0 deletions
55
sdk/python/tests/compiler/testdata/loop_static_with_parallelism.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,55 @@ | ||
# 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 kfp.dsl as dsl | ||
from kfp_tekton.compiler import TektonCompiler | ||
|
||
|
||
class Coder: | ||
def empty(self): | ||
return "" | ||
|
||
|
||
TektonCompiler._get_unique_id_code = Coder.empty | ||
|
||
|
||
@dsl.pipeline(name='para-loop-pipeline') | ||
def pipeline(my_pipe_param='10'): | ||
loop_args = [1, 2, 3] | ||
with dsl.ParallelFor(loop_args=loop_args, parallelism=5) as item: | ||
op1 = dsl.ContainerOp( | ||
name="para-loop-inner-op1", | ||
image="library/bash:4.4.23", | ||
command=["sh", "-c"], | ||
arguments=["echo op1 %s %s" % (item, my_pipe_param)], | ||
) | ||
|
||
op2 = dsl.ContainerOp( | ||
name="para-loop-inner-op2", | ||
image="library/bash:4.4.23", | ||
command=["sh", "-c"], | ||
arguments=["echo op2 %s" % item], | ||
) | ||
|
||
op_out = dsl.ContainerOp( | ||
name="para-loop-out-op", | ||
image="library/bash:4.4.23", | ||
command=["sh", "-c"], | ||
arguments=["echo %s" % my_pipe_param], | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
from kfp_tekton.compiler import TektonCompiler | ||
TektonCompiler().compile(pipeline, __file__.replace('.py', '.yaml')) |
72 changes: 72 additions & 0 deletions
72
sdk/python/tests/compiler/testdata/loop_static_with_parallelism.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,72 @@ | ||
# 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: '{"inputs": [{"default": "10", "name": "my_pipe_param", | ||
"optional": true}], "name": "para-loop-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: '{"para-loop-inner-op1": [], "para-loop-inner-op2": | ||
[], "para-loop-out-op": []}' | ||
tekton.dev/input_artifacts: '{}' | ||
tekton.dev/output_artifacts: '{}' | ||
name: para-loop-pipeline | ||
spec: | ||
params: | ||
- name: my_pipe_param | ||
value: '10' | ||
pipelineSpec: | ||
params: | ||
- default: '10' | ||
name: my_pipe_param | ||
tasks: | ||
- name: para-loop-out-op | ||
params: | ||
- name: my_pipe_param | ||
value: $(params.my_pipe_param) | ||
taskSpec: | ||
metadata: | ||
annotations: | ||
tekton.dev/template: '' | ||
labels: | ||
pipelines.kubeflow.org/cache_enabled: 'true' | ||
pipelines.kubeflow.org/generation: '' | ||
pipelines.kubeflow.org/pipelinename: '' | ||
params: | ||
- name: my_pipe_param | ||
steps: | ||
- args: | ||
- echo $(inputs.params.my_pipe_param) | ||
command: | ||
- sh | ||
- -c | ||
image: library/bash:4.4.23 | ||
name: main | ||
timeout: 0s | ||
- name: para-loop-pipeline-for-loop-2 | ||
params: | ||
- name: loop-item-param-1 | ||
value: '[1, 2, 3]' | ||
- name: my_pipe_param | ||
value: $(params.my_pipe_param) | ||
taskRef: | ||
apiVersion: custom.tekton.dev/v1alpha1 | ||
kind: PipelineLoop | ||
name: para-loop-pipeline-for-loop-2 | ||
timeout: 0s |
80 changes: 80 additions & 0 deletions
80
sdk/python/tests/compiler/testdata/loop_static_with_parallelism_pipelineloop_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,80 @@ | ||
# 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.tekton.dev/v1alpha1 | ||
kind: PipelineLoop | ||
metadata: | ||
name: para-loop-pipeline-for-loop-2 | ||
spec: | ||
pipelineSpec: | ||
params: | ||
- name: loop-item-param-1 | ||
type: string | ||
- name: my_pipe_param | ||
type: string | ||
tasks: | ||
- name: para-loop-inner-op1 | ||
params: | ||
- name: loop-item-param-1 | ||
value: $(params.loop-item-param-1) | ||
- name: my_pipe_param | ||
value: $(params.my_pipe_param) | ||
taskSpec: | ||
steps: | ||
- name: main | ||
args: | ||
- echo op1 $(inputs.params.loop-item-param-1) $(inputs.params.my_pipe_param) | ||
command: | ||
- sh | ||
- -c | ||
image: library/bash:4.4.23 | ||
params: | ||
- name: loop-item-param-1 | ||
type: string | ||
- name: my_pipe_param | ||
type: string | ||
metadata: | ||
labels: | ||
pipelines.kubeflow.org/pipelinename: '' | ||
pipelines.kubeflow.org/generation: '' | ||
pipelines.kubeflow.org/cache_enabled: "true" | ||
annotations: | ||
tekton.dev/template: '' | ||
timeout: 0s | ||
- name: para-loop-inner-op2 | ||
params: | ||
- name: loop-item-param-1 | ||
value: $(params.loop-item-param-1) | ||
taskSpec: | ||
steps: | ||
- name: main | ||
args: | ||
- echo op2 $(inputs.params.loop-item-param-1) | ||
command: | ||
- sh | ||
- -c | ||
image: library/bash:4.4.23 | ||
params: | ||
- name: loop-item-param-1 | ||
type: string | ||
metadata: | ||
labels: | ||
pipelines.kubeflow.org/pipelinename: '' | ||
pipelines.kubeflow.org/generation: '' | ||
pipelines.kubeflow.org/cache_enabled: "true" | ||
annotations: | ||
tekton.dev/template: '' | ||
timeout: 0s | ||
parallelism: 5 | ||
iterateParam: loop-item-param-1 |
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,2 @@ | ||
.ko.yaml | ||
|