-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support pipeline level imagepullsecret in DSL (#745)
* support pipeline level imagepullsecret in DSL * use kubernetes native input parameter for imagepullsecrets * expose a module level function to configure the pipeline settings for the current default pipeline
- Loading branch information
1 parent
cea1632
commit 9ebbaa3
Showing
6 changed files
with
154 additions
and
1 deletion.
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
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,50 @@ | ||
# 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 kfp.dsl as dsl | ||
from kubernetes import client as k8s_client | ||
|
||
|
||
class GetFrequentWordOp(dsl.ContainerOp): | ||
"""A get frequent word class representing a component in ML Pipelines. | ||
The class provides a nice interface to users by hiding details such as container, | ||
command, arguments. | ||
""" | ||
def __init__(self, name, message): | ||
"""Args: | ||
name: An identifier of the step which needs to be unique within a pipeline. | ||
message: a dsl.PipelineParam object representing an input message. | ||
""" | ||
super(GetFrequentWordOp, self).__init__( | ||
name=name, | ||
image='python:3.5-jessie', | ||
command=['sh', '-c'], | ||
arguments=['python -c "from collections import Counter; ' | ||
'words = Counter(\'%s\'.split()); print(max(words, key=words.get))" ' | ||
'| tee /tmp/message.txt' % message], | ||
file_outputs={'word': '/tmp/message.txt'}) | ||
|
||
@dsl.pipeline( | ||
name='Save Most Frequent', | ||
description='Get Most Frequent Word and Save to GCS' | ||
) | ||
def save_most_frequent_word(message: str): | ||
"""A pipeline function describing the orchestration of the workflow.""" | ||
|
||
counter = GetFrequentWordOp( | ||
name='get-Frequent', | ||
message=message) | ||
dsl.get_pipeline_conf().set_image_pull_secrets([k8s_client.V1ObjectReference(name="secretA")]) |
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,69 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: save-most-frequent- | ||
spec: | ||
arguments: | ||
parameters: | ||
- name: message | ||
entrypoint: save-most-frequent | ||
imagePullSecrets: | ||
- name: secretA | ||
serviceAccountName: pipeline-runner | ||
templates: | ||
- container: | ||
args: | ||
- python -c "from collections import Counter; words = Counter('{{inputs.parameters.message}}'.split()); | ||
print(max(words, key=words.get))" | tee /tmp/message.txt | ||
command: | ||
- sh | ||
- -c | ||
image: python:3.5-jessie | ||
inputs: | ||
parameters: | ||
- name: message | ||
name: get-frequent | ||
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 | ||
parameters: | ||
- name: get-frequent-word | ||
valueFrom: | ||
path: /tmp/message.txt | ||
- dag: | ||
tasks: | ||
- arguments: | ||
parameters: | ||
- name: message | ||
value: '{{inputs.parameters.message}}' | ||
name: get-frequent | ||
template: get-frequent | ||
inputs: | ||
parameters: | ||
- name: message | ||
name: save-most-frequent |