This repository was archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathupdate-model-pr-task.yaml
174 lines (173 loc) · 6.25 KB
/
update-model-pr-task.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# A Tekton Task to update the model, and create a PR
#
# Modifications are based on running kpt set
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: clone-modify-pr
annotations:
# This gets passed down to the individual pods
sidecar.istio.io/inject: "false"
spec:
params:
- name: automl-model
description: "The name of the automl-model to use in the form projects/${PROJECT}/locations/${LOCATION}/models/${ID}"
- name: branchName
type: string
description: The name to give to the branch to create
- name: fork
type: string
default: fork
description: The url of the remote repo for the fork
- name: forkName
type: string
default: fork
description: (Optional) The name to give to the remote repo for the fork
- name: upstreamName
type: string
default: origin
description: (Optional) The name of the remote repository corresponding to the
upstream URL
#**********************************************************************
# Create PR parameters
- name: gitHubAppId
type: string
default: "71466"
description: AppID for the GitHub app used to create PRs
- name: forkOwner
type: string
default: kubeflow
description: (Optional) The GitHub org/user that is the owner of the fork repository
- name: gitHubAppPrivateKeySecretName
type: string
default: label-bot-cd-github-private-key
description: Name of the secret containing the github app private key
- name: gitHubAppPrivateKeyFileName
type: string
default: github-private-key
description: Name of the file in gitHubAppPrivateKeySecretName containing the
private key
#**********************************************************************
# Image parameters
- name: prctl-image
type: string
default: "gcr.io/kubeflow-images-public/prctl:a1a488e@sha256:53b4e6ff048adf8a4f9afc623e533456c7ace944f9bf03c527f07e597c86ae8c"
description: The image containing prctl
- name: kpt-image
type: string
# Should be 0.30.1 kpt image
default: gcr.io/kpt-dev/kpt@sha256:8a621c8e4b4d1cf5ec71f43aa099c120a78291896664a2cdb2c965a5726479ad
description: kpt image to use
- name: automl-image
type: string
default: gcr.io/issue-label-bot-dev/labelbot-diff@sha256:ce3feb1b3f8f27bacd122a50e8df8582204c2eade6854daca47c02a3ca748a6d # {"$kpt-set":"labelbot-diff-image"}
description: The image containing the AutoML CLI used to deploy models
resources:
inputs:
- name: repo
type: git
description: The GitHub repo containing the code to modify
steps:
# Ensure the model is deployed
- name: deploy
image: $(inputs.params.automl-image)
# Need to use script as workaround not to error out in tests.
# If any of the steps returns non-zero codes, subsequent steps will not be run.
# See: https://github.com/tektoncd/pipeline/issues/2316
# With workload identity we need to specify the entrypoint so Tekton doesn't have to look it up.
command:
- /automl
- deploy
- --model=$(inputs.params.automl-model)
# Create a branch
- name: branch
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
# Need to use script as workaround not to error out in tests.
# If any of the steps returns non-zero codes, subsequent steps will not be run.
args:
- branch
- --json-logs
- --branchName=$(inputs.params.branchName)
- --fork=$(inputs.params.fork)
- --forkName=$(inputs.params.forkName)
- --repoDir=/workspace/$(inputs.resources.repo.name)
- --upstreamName=$(inputs.params.upstreamName)
# Modify the model
- name: kpt-set
image: $(inputs.params.kpt-image)
workingDir: /workspace/$(inputs.resources.repo.name)
command:
- kpt
- cfg
- set
- /workspace/$(inputs.resources.repo.name)/Label_Microservice/deployment
- automl-model
- $(inputs.params.automl-model)
# Hydrate the manifests
- name: hydrate
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)/Label_Microservice
command:
- make
- hydrate-prod
- name: git-configure
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
script: |
#!/usr/bin/env bash
set -x
git config --global user.email label-bot@label-bot.dev
git config --global user.name "Label bot"
# Commit and push the changes
- name: create-message
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
script: |
#!/usr/bin/env bash
set -x
cat << 'EOF' >> /workspace/message.txt
[auto PR] Update model to $(inputs.params.automl-model)
Update the automl-model to $(inputs.params.automl-model)
EOF
- name: commit-push
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
script: |-
#!/usr/bin/env bash
set -x
# We need to create a symbolic link to the ssh files that Tekton sets up
ln -sf /tekton/home/.ssh /root/.ssh
prctl push \
--json-logs \
--refSpec=$(inputs.params.branchName) \
--forkName=$(inputs.params.forkName) \
--repoDir=/workspace/$(inputs.resources.repo.name) \
--messagePath=/workspace/message.txt
# TODO(jlewi): Should we make creating a PR its own task?
# How would we make the message available to it? We could get the message
# of the last commit if we checkout the repo? Is it possible to do that
# using the GitHub API?
#
- name: create-pr
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
script: |-
#!/usr/bin/env bash
set -x
# Uncomment to stop debugging
prctl pull-request \
--json-logs \
--privateKey=/secret/$(inputs.params.gitHubAppPrivateKeyFileName) \
--repo=$(inputs.resources.repo.url) \
--baseBranch=$(inputs.resources.repo.revision) \
--forkRef=$(inputs.params.forkOwner):$(inputs.params.branchName) \
--appId=$(inputs.params.gitHubAppId) \
--messagePath=/workspace/message.txt
volumeMounts:
- mountPath: /secret
name: github-bot-private-key
volumes:
- name: github-bot-private-key
secret:
secretName: $(inputs.params.gitHubAppPrivateKeySecretName)