-
Notifications
You must be signed in to change notification settings - Fork 21
111 lines (93 loc) · 3.38 KB
/
cd-training-pipeline.yml
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
name: Trigger Training Pipeline
on:
workflow_dispatch:
inputs:
gcpProject:
description: 'GCP Project for Vertex AI Pipeline'
required: true
default: 'gcp-ml-172005'
gcpRegion:
description: 'GCP Region for Vertex AI Pipeline'
required: true
default: 'us-central1'
pipelineName:
description: 'TFX Pipeline Name to Trigger'
required: true
default: 'segmentation-training-pipeline'
enableDataflow:
description: 'use the full resolution data, dataflow'
required: true
default: 'false'
jobs:
cd:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: 'Install required Python packages'
run: |
pip install -r requirements.txt
- name: 'Replace GCP Project Strings'
id: prepare-step
run: |
gcp_key=`echo ${{ github.event.inputs.gcpProject }} | sed -e "s/-/_/g"`
echo "::set-output name=GCP_SECRET_KEY::$gcp_key"
- name: 'Replace GCP Project in config.py'
working-directory: 'training_pipeline'
run: |
sed -i 's/gcp-ml-172005/${{ github.event.inputs.gcpProject }}/g' pipeline/configs.py
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
env:
GCP_SECRET_KEY: ${{ steps.prepare-step.outputs.GCP_SECRET_KEY }}
with:
credentials_json: '${{ secrets[env.GCP_SECRET_KEY] }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v0'
- name: 'Set up docker auth in gcloud'
run: |
gcloud --quiet auth configure-docker
- name: 'Replace Access Token Placeholder'
working-directory: 'training_pipeline'
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
HF_ACCESS_TOKEN: ${{ secrets.HF_ACCESS_TOKEN }}
run: |
envsubst '$GH_ACCESS_TOKEN, $HF_ACCESS_TOKEN' < pipeline/configs.py > pipeline/configs_tmp.py
mv pipeline/configs_tmp.py pipeline/configs.py
cat pipeline/configs.py
- name: 'Create TFX Training Pipeline'
working-directory: 'training_pipeline'
env:
ENABLE_DATAFLOW: ${{ github.event.inputs.enableDataflow }}
run: |
ENABLE_DATAFLOW=${{ env.ENABLE_DATAFLOW }} \
tfx pipeline create \
--pipeline-path kubeflow_runner.py \
--engine vertex \
--build-image
- name: 'Compile TFX Training Pipeline'
working-directory: 'training_pipeline'
env:
ENABLE_DATAFLOW: ${{ github.event.inputs.enableDataflow }}
run: |
ENABLE_DATAFLOW=${{ env.ENABLE_DATAFLOW }} \
tfx pipeline compile \
--pipeline-path kubeflow_runner.py \
--engine vertex
- name: 'Run TFX Training Pipeline'
working-directory: 'training_pipeline'
env:
ENABLE_DATAFLOW: ${{ github.event.inputs.enableDataflow }}
run: |
ENABLE_DATAFLOW=${{ env.ENABLE_DATAFLOW }} \
tfx run create \
--engine vertex \
--pipeline-name ${{ github.event.inputs.pipelineName }} \
--project ${{ github.event.inputs.gcpProject }} \
--region ${{ github.event.inputs.gcpRegion }}