-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK - Added support for raw artifact values to ContainerOp
- Loading branch information
Showing
6 changed files
with
229 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
60 changes: 60 additions & 0 deletions
60
sdk/python/tests/compiler/testdata/input_artifact_raw_value.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,60 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2018 Google LLC | ||
# | ||
# 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 sys | ||
from pathlib import Path | ||
|
||
sys.path.insert(0, __file__ + '/../../../../') | ||
|
||
import kfp.dsl as dsl | ||
|
||
def component_with_input_artifact(text): | ||
'''A component that passes text as input artifact''' | ||
|
||
text_input_path = '/inputs/text/data' | ||
return dsl.ContainerOp( | ||
name='component_with_input_artifact', | ||
input_artifact_paths={'text': text_input_path}, | ||
input_artifact_arguments={'text': text}, | ||
image='alpine', | ||
command=['cat', text_input_path], | ||
) | ||
|
||
def component_with_hardcoded_input_artifact_value(): | ||
'''A component that passes hard-coded text as input artifact''' | ||
return component_with_input_artifact('hard-coded artifact value') | ||
|
||
|
||
def component_with_input_artifact_value_from_file(file_path): | ||
'''A component that passes contents of a file as input artifact''' | ||
return component_with_input_artifact(Path(file_path).read_text()) | ||
|
||
|
||
file_path = str(Path(__file__).parent.joinpath('input_artifact_raw_value.txt')) | ||
|
||
|
||
@dsl.pipeline( | ||
name='pipeline includes two steps which fail randomly.', | ||
description='shows how to use ContainerOp set_retry().' | ||
) | ||
def retry_sample_pipeline(): | ||
component_with_input_artifact('Constant artifact value') | ||
component_with_hardcoded_input_artifact_value() | ||
component_with_input_artifact_value_from_file(file_path) | ||
|
||
if __name__ == '__main__': | ||
import kfp.compiler as compiler | ||
compiler.Compiler().compile(retry_sample_pipeline, __file__ + '.tar.gz') |
1 change: 1 addition & 0 deletions
1
sdk/python/tests/compiler/testdata/input_artifact_raw_value.txt
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 @@ | ||
Text from a file with hard-coded artifact value |
139 changes: 139 additions & 0 deletions
139
sdk/python/tests/compiler/testdata/input_artifact_raw_value.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,139 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: pipeline-includes-two-steps-which-fail-randomly- | ||
spec: | ||
arguments: | ||
parameters: [] | ||
entrypoint: pipeline-includes-two-steps-which-fail-randomly | ||
serviceAccountName: pipeline-runner | ||
templates: | ||
- container: | ||
command: | ||
- cat | ||
- /inputs/text/data | ||
image: alpine | ||
inputs: | ||
artifacts: | ||
- name: text | ||
path: /inputs/text/data | ||
raw: | ||
data: Constant artifact value | ||
name: component-with-input-artifact | ||
outputs: | ||
artifacts: | ||
- name: mlpipeline-ui-metadata | ||
path: /mlpipeline-ui-metadata.json | ||
s3: | ||
accessKeySecret: | ||
key: accesskey | ||
name: mlpipeline-minio-artifact | ||
bucket: mlpipeline | ||
endpoint: minio-service.kubeflow:9000 | ||
insecure: true | ||
key: runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz | ||
secretKeySecret: | ||
key: secretkey | ||
name: mlpipeline-minio-artifact | ||
- name: mlpipeline-metrics | ||
path: /mlpipeline-metrics.json | ||
s3: | ||
accessKeySecret: | ||
key: accesskey | ||
name: mlpipeline-minio-artifact | ||
bucket: mlpipeline | ||
endpoint: minio-service.kubeflow:9000 | ||
insecure: true | ||
key: runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-metrics.tgz | ||
secretKeySecret: | ||
key: secretkey | ||
name: mlpipeline-minio-artifact | ||
- container: | ||
command: | ||
- cat | ||
- /inputs/text/data | ||
image: alpine | ||
inputs: | ||
artifacts: | ||
- name: text | ||
path: /inputs/text/data | ||
raw: | ||
data: hard-coded artifact value | ||
name: component-with-input-artifact-2 | ||
outputs: | ||
artifacts: | ||
- name: mlpipeline-ui-metadata | ||
path: /mlpipeline-ui-metadata.json | ||
s3: | ||
accessKeySecret: | ||
key: accesskey | ||
name: mlpipeline-minio-artifact | ||
bucket: mlpipeline | ||
endpoint: minio-service.kubeflow:9000 | ||
insecure: true | ||
key: runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz | ||
secretKeySecret: | ||
key: secretkey | ||
name: mlpipeline-minio-artifact | ||
- name: mlpipeline-metrics | ||
path: /mlpipeline-metrics.json | ||
s3: | ||
accessKeySecret: | ||
key: accesskey | ||
name: mlpipeline-minio-artifact | ||
bucket: mlpipeline | ||
endpoint: minio-service.kubeflow:9000 | ||
insecure: true | ||
key: runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-metrics.tgz | ||
secretKeySecret: | ||
key: secretkey | ||
name: mlpipeline-minio-artifact | ||
- container: | ||
command: | ||
- cat | ||
- /inputs/text/data | ||
image: alpine | ||
inputs: | ||
artifacts: | ||
- name: text | ||
path: /inputs/text/data | ||
raw: | ||
data: Text from a file with hard-coded artifact value | ||
name: component-with-input-artifact-2-3 | ||
outputs: | ||
artifacts: | ||
- name: mlpipeline-ui-metadata | ||
path: /mlpipeline-ui-metadata.json | ||
s3: | ||
accessKeySecret: | ||
key: accesskey | ||
name: mlpipeline-minio-artifact | ||
bucket: mlpipeline | ||
endpoint: minio-service.kubeflow:9000 | ||
insecure: true | ||
key: runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz | ||
secretKeySecret: | ||
key: secretkey | ||
name: mlpipeline-minio-artifact | ||
- name: mlpipeline-metrics | ||
path: /mlpipeline-metrics.json | ||
s3: | ||
accessKeySecret: | ||
key: accesskey | ||
name: mlpipeline-minio-artifact | ||
bucket: mlpipeline | ||
endpoint: minio-service.kubeflow:9000 | ||
insecure: true | ||
key: runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-metrics.tgz | ||
secretKeySecret: | ||
key: secretkey | ||
name: mlpipeline-minio-artifact | ||
- dag: | ||
tasks: | ||
- name: component-with-input-artifact | ||
template: component-with-input-artifact | ||
- name: component-with-input-artifact-2 | ||
template: component-with-input-artifact-2 | ||
- name: component-with-input-artifact-2-3 | ||
template: component-with-input-artifact-2-3 | ||
name: pipeline-includes-two-steps-which-fail-randomly |