forked from opendatahub-io/data-science-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sdk): Fix big data passing with multiple type of volume templates (…
…kubeflow#1006) * fix big data passing with multiple type of volume templates * fix lint and license * fix multi input step bug * refactor update volume code * add missing tests
- Loading branch information
Showing
7 changed files
with
512 additions
and
15 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
106 changes: 106 additions & 0 deletions
106
sdk/python/tests/compiler/testdata/big_data_multi_volumes_1.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,106 @@ | ||
# Copyright 2022 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.components import load_component_from_text | ||
from kfp_tekton.compiler import TektonCompiler | ||
from kubernetes.client import V1Volume, V1VolumeMount, V1SecretVolumeSource | ||
|
||
|
||
def PrintOp(name: str, msg: str = None): | ||
if msg is None: | ||
msg = name | ||
print_op = load_component_from_text( | ||
""" | ||
name: %s | ||
inputs: | ||
- {name: input_text, type: String, description: 'Represents an input parameter.'} | ||
outputs: | ||
- {name: output_value, type: String, description: 'Represents an output parameter.'} | ||
implementation: | ||
container: | ||
image: alpine:3.6 | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
set -e | ||
echo $0 > $1 | ||
- {inputValue: input_text} | ||
- {outputPath: output_value} | ||
""" % name | ||
) | ||
return print_op(msg) | ||
|
||
|
||
def PrintRefOp(name: str, msg: str = None): | ||
if msg is None: | ||
msg = name | ||
print_op = load_component_from_text( | ||
""" | ||
name: %s | ||
inputs: | ||
- {name: input_text, type: String, description: 'Represents an input parameter.'} | ||
outputs: | ||
- {name: output_value, type: String, description: 'Represents an output parameter.'} | ||
implementation: | ||
container: | ||
image: alpine:3.6 | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
set -e | ||
cat $0 > $1 | ||
- {inputPath: input_text} | ||
- {outputPath: output_value} | ||
""" % name | ||
) | ||
return print_op(msg) | ||
|
||
|
||
def add_volume_and_mount(op: dsl.ContainerOp) -> dsl.ContainerOp: | ||
suffix = op.name[op.name.index('-'):] | ||
return op.add_volume( | ||
V1Volume( | ||
name='volume' + suffix, | ||
secret=V1SecretVolumeSource(secret_name='secret' + suffix), | ||
) | ||
).container.add_volume_mount( | ||
V1VolumeMount( | ||
name='volume' + suffix, | ||
mount_path='/volume' + suffix, | ||
) | ||
) | ||
|
||
|
||
@dsl.pipeline(name='big-data') | ||
def big_data(): | ||
# literal -> small | ||
PrintOp( | ||
'print-sm', | ||
'literal', | ||
).apply(add_volume_and_mount) | ||
|
||
# literal -> big | ||
PrintRefOp( | ||
'print-big', | ||
'literal', | ||
).apply(add_volume_and_mount) | ||
|
||
|
||
if __name__ == '__main__': | ||
from kfp_tekton.compiler import TektonCompiler | ||
TektonCompiler().compile(big_data, __file__.replace('.py', '.yaml')) |
120 changes: 120 additions & 0 deletions
120
sdk/python/tests/compiler/testdata/big_data_multi_volumes_1.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,120 @@ | ||
# 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: | ||
name: big-data | ||
annotations: | ||
tekton.dev/output_artifacts: '{"print-big": [{"key": "artifacts/$PIPELINERUN/print-big/output_value.tgz", | ||
"name": "print-big-output_value", "path": "/tmp/outputs/output_value/data"}], | ||
"print-sm": [{"key": "artifacts/$PIPELINERUN/print-sm/output_value.tgz", "name": | ||
"print-sm-output_value", "path": "/tmp/outputs/output_value/data"}]}' | ||
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: '{"print-big": [["output_value", "$(results.output-value.path)"]], | ||
"print-sm": [["output_value", "$(results.output-value.path)"]]}' | ||
sidecar.istio.io/inject: "false" | ||
pipelines.kubeflow.org/big_data_passing_format: $(workspaces.$TASK_NAME.path)/artifacts/$ORIG_PR_NAME/$TASKRUN_NAME/$TASK_PARAM_NAME | ||
pipelines.kubeflow.org/pipeline_spec: '{"name": "big-data"}' | ||
spec: | ||
pipelineSpec: | ||
tasks: | ||
- name: print-sm | ||
taskSpec: | ||
steps: | ||
- name: main | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
set -e | ||
echo $0 > $1 | ||
- literal | ||
- $(results.output-value.path) | ||
image: alpine:3.6 | ||
volumeMounts: | ||
- mountPath: /volume-sm | ||
name: volume-sm | ||
results: | ||
- name: output-value | ||
type: string | ||
description: /tmp/outputs/output_value/data | ||
volumes: | ||
- name: volume-sm | ||
secret: | ||
secretName: secret-sm | ||
metadata: | ||
labels: | ||
pipelines.kubeflow.org/pipelinename: '' | ||
pipelines.kubeflow.org/generation: '' | ||
pipelines.kubeflow.org/cache_enabled: "true" | ||
annotations: | ||
pipelines.kubeflow.org/component_spec_digest: '{"name": "print-sm", "outputs": | ||
[{"description": "Represents an output parameter.", "name": "output_value", | ||
"type": "String"}], "version": "print-sm@sha256=e88f5ee1607e92e4cf859907b2f81bdc766fc69cff62010f2f93d4c850a4d429"}' | ||
tekton.dev/template: '' | ||
timeout: 525600m | ||
- name: print-big | ||
taskSpec: | ||
steps: | ||
- image: busybox | ||
name: copy-inputs | ||
command: | ||
- sh | ||
- -ec | ||
- | | ||
set -exo pipefail | ||
echo -n "literal" > /tmp/inputs/input_text/data | ||
- name: main | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
set -e | ||
cat $0 > $1 | ||
- /tmp/inputs/input_text/data | ||
- $(results.output-value.path) | ||
image: alpine:3.6 | ||
volumeMounts: | ||
- mountPath: /volume-big | ||
name: volume-big | ||
results: | ||
- name: output-value | ||
type: string | ||
description: /tmp/outputs/output_value/data | ||
volumes: | ||
- name: volume-big | ||
secret: | ||
secretName: secret-big | ||
- name: input-text | ||
emptyDir: {} | ||
metadata: | ||
labels: | ||
pipelines.kubeflow.org/pipelinename: '' | ||
pipelines.kubeflow.org/generation: '' | ||
pipelines.kubeflow.org/cache_enabled: "true" | ||
annotations: | ||
pipelines.kubeflow.org/component_spec_digest: '{"name": "print-big", "outputs": | ||
[{"description": "Represents an output parameter.", "name": "output_value", | ||
"type": "String"}], "version": "print-big@sha256=e85f43e32a0210be43f84f43434e61113ce4770f37f5346acc41523a270e72d4"}' | ||
tekton.dev/template: '' | ||
stepTemplate: | ||
volumeMounts: | ||
- name: input-text | ||
mountPath: /tmp/inputs/input_text | ||
timeout: 525600m | ||
timeout: 525600m |
Oops, something went wrong.