-
Notifications
You must be signed in to change notification settings - Fork 127
/
model-deployment.yaml
78 lines (71 loc) · 2.51 KB
/
model-deployment.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
# Copyright 2021 Google Inc. All Rights Reserved.
#
# 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.
######################################################################
# CI/CD steps for Cloud Build to test and deploy a model to Vertex AI.
######################################################################
steps:
# Clone the repository.
- name: 'gcr.io/cloud-builders/git'
args: ['clone', '--single-branch', '--branch',
'$_BRANCH', '$_REPO_URL',
'--depth', '1',
'--verbose']
id: 'Clone Repository'
# Test uploaded model artifact.
- name: '$_CICD_IMAGE_URI'
entrypoint: 'pytest'
args: ['src/tests/model_deployment_tests.py::test_model_artifact']
dir: 'mlops-with-vertex-ai'
env:
- 'PROJECT=$_PROJECT'
- 'REGION=$_REGION'
- 'MODEL_DISPLAY_NAME=$_MODEL_DISPLAY_NAME'
id: 'Test Model Artifact'
waitFor: ['Clone Repository']
# Create an endpoint.
- name: '$_CICD_IMAGE_URI'
entrypoint: 'python'
args: ['build/utils.py',
'--mode', 'create-endpoint',
'--project', '$_PROJECT',
'--region', '$_REGION',
'--endpoint-display-name', '$_ENDPOINT_DISPLAY_NAME']
dir: 'mlops-with-vertex-ai'
id: 'Create Endpoint'
waitFor: ['Test Model Artifact']
# Deploy the model.
- name: '$_CICD_IMAGE_URI'
entrypoint: 'python'
args: ['build/utils.py',
'--mode', 'deploy-model',
'--project', '$_PROJECT',
'--region', '$_REGION',
'--endpoint-display-name', '$_ENDPOINT_DISPLAY_NAME',
'--model-display-name', '$_MODEL_DISPLAY_NAME'
]
dir: 'mlops-with-vertex-ai'
id: 'Deploy Model'
waitFor: ['Create Endpoint']
# Test deployed model endpoint.
- name: '$_CICD_IMAGE_URI'
entrypoint: 'pytest'
args: ['src/tests/model_deployment_tests.py::test_model_endpoint']
dir: 'mlops-with-vertex-ai'
env:
- 'PROJECT=$_PROJECT'
- 'REGION=$_REGION'
- 'MODEL_DISPLAY_NAME=$_MODEL_DISPLAY_NAME'
- 'ENDPOINT_DISPLAY_NAME=$_ENDPOINT_DISPLAY_NAME'
id: 'Test Model Endpoint'
waitFor: ['Deploy Model']