-
Notifications
You must be signed in to change notification settings - Fork 127
/
pipeline-deployment.yaml
112 lines (95 loc) · 3.38 KB
/
pipeline-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
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
# 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 TFX pipeline 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'
# Run datasource_utils unit tests.
- name: '$_CICD_IMAGE_URI'
entrypoint: 'pytest'
args: ['src/tests/datasource_utils_tests.py', '-s']
dir: 'mlops-with-vertex-ai'
env:
- 'PROJECT=$_PROJECT'
- 'BQ_LOCATION=$_BQ_LOCATION'
- 'BQ_DATASET_NAME=$_BQ_DATASET_NAME'
- 'BQ_TABLE_NAME=$_BQ_TABLE_NAME'
id: 'Unit Test Datasource Utils'
waitFor: ['Clone Repository']
# Run model unit tests.
- name: '$_CICD_IMAGE_URI'
entrypoint: 'pytest'
args: ['src/tests/model_tests.py', '-s']
dir: 'mlops-with-vertex-ai'
id: 'Unit Test Model'
waitFor: ['Clone Repository']
timeout: 1800s
# Test e2e pipeline using local runner.
- name: '$_CICD_IMAGE_URI'
entrypoint: 'pytest'
args: ['src/tests/pipeline_deployment_tests.py::test_e2e_pipeline', '-s']
dir: 'mlops-with-vertex-ai'
env:
- 'PROJECT=$_PROJECT'
- 'REGION=$_REGION'
- 'MODEL_DISPLAY_NAME=$_MODEL_DISPLAY_NAME'
- 'DATASET_DISPLAY_NAME=$_DATASET_DISPLAY_NAME'
- 'GCS_LOCATION=$_TEST_GCS_LOCATION'
- 'TRAIN_LIMIT=$_CI_TRAIN_LIMIT'
- 'TEST_LIMIT=$_CI_TEST_LIMIT'
- 'UPLOAD_MODEL=$_CI_UPLOAD_MODEL'
- 'ACCURACY_THRESHOLD=$_CI_ACCURACY_THRESHOLD'
id: 'Local Test E2E Pipeline'
waitFor: ['Unit Test Datasource Utils', 'Unit Test Model']
timeout: 1800s
# Build the image that encapsulates the pipeline.
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', '$_TFX_IMAGE_URI', '.']
dir: 'mlops-with-vertex-ai'
id: 'Build TFX Image'
waitFor: ['Local Test E2E Pipeline']
# Compile the pipeline.
- name: '$_CICD_IMAGE_URI'
entrypoint: 'python'
args: ['build/utils.py',
'--mode', 'compile-pipeline',
'--pipeline-name', '$_PIPELINE_NAME'
]
dir: 'mlops-with-vertex-ai'
env:
- 'PROJECT=$_PROJECT'
- 'REGION=$_REGION'
- 'MODEL_DISPLAY_NAME=$_MODEL_DISPLAY_NAME'
- 'DATASET_DISPLAY_NAME=$_DATASET_DISPLAY_NAME'
- 'GCS_LOCATION=$_GCS_LOCATION'
- 'TFX_IMAGE_URI=$_TFX_IMAGE_URI'
- 'BEAM_RUNNER=$_BEAM_RUNNER'
- 'TRAINING_RUNNER=$_TRAINING_RUNNER'
id: 'Compile Pipeline'
waitFor: ['Local Test E2E Pipeline']
# Upload compiled pipeline to GCS.
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', '$_PIPELINE_NAME.json', '$_PIPELINES_STORE']
dir: 'mlops-with-vertex-ai'
id: 'Upload Pipeline to GCS'
waitFor: ['Compile Pipeline']
# Push TFX Image to Container Registy.
images: ['$_TFX_IMAGE_URI']