-
Notifications
You must be signed in to change notification settings - Fork 152
202 lines (186 loc) · 8.19 KB
/
run_one_use_cases_example.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Run One Use Case Example
on:
workflow_dispatch:
inputs:
use_case:
description: 'Select a use case to run'
required: true
type: choice
options:
# --- refresh_use_cases_list.py: refresh list of use cases currently available [START] ---
# --- do not edit, auto generated part by `make refresh_use_cases_list` ---
- cifar/cifar_brevitas_finetuning
- cifar/cifar_brevitas_training
- credit_scoring
- deployment/breast_cancer
- deployment/cifar
- deployment/sentiment_analysis
- disease_prediction
- federated_learning
- hybrid_model
- llm
- lora_finetuning
- resnet
- sentiment_analysis_with_transformer
- titanic
# --- refresh_use_cases_list.py: refresh list of use cases currently available [END] ---
push_changes:
description: 'Push refreshed notebook(s)'
required: false
type: boolean
default: false
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
jobs:
start-runner-linux:
name: Start EC2 runner
runs-on: ubuntu-20.04
outputs:
label-38: ${{ steps.start-ec2-runner-38.outputs.label }}
ec2-instance-id-38: ${{ steps.start-ec2-runner-38.outputs.ec2-instance-id || '' }}
steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner python 38
id: start-ec2-runner-38
uses: machulav/ec2-github-runner@1827d6ca7544d7044ddbd2e9360564651b463da2
with:
mode: start
github-token: ${{ secrets.EC2_RUNNER_BOT_TOKEN }}
ec2-image-id: ${{ secrets.AWS_EC2_AMI }}
ec2-instance-type: "m6i.metal"
subnet-id: ${{ secrets.AWS_EC2_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_EC2_SECURITY_GROUP_ID }}
run-use-case-examples:
needs: [start-runner-linux]
runs-on: ${{ needs.start-runner-linux.outputs.label-38 }}
container:
image: ubuntu:20.04
defaults:
run:
shell: bash
steps:
- name: Install Docker and Dependencies
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release \
python3-venv \
make \
git \
git-lfs \
binutils
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
apt-get install -y python3-venv make git git-lfs binutils
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
lfs: true
- name: Run One Use Case Example Script
run: |
USE_CASE=${{ github.event.inputs.use_case }}
make run_one_use_case_example USE_CASE=$USE_CASE
# Pull the latest changes if there are some
- name: Pull latest changes
if: ${{ github.event.inputs.push_changes == 'true' }}
run: |
git pull -X theirs
# If the target branch is main or a release branch, a Pull Request is opened for everyone to
# review.
- name: Open PR
if: ${{ github.event.inputs.push_changes == 'true' && (github.ref_name == 'main' || startsWith(github.ref_name , 'release/')) }}
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f
with:
token: ${{ secrets.BOT_TOKEN }}
commit-message: "chore: refresh notebook(s) for use case ${{ github.event.inputs.use_case }}"
branch: "refresh-notebook(s)-for-use-case-${{ github.event.inputs.use_case }}-for-branch-${{ github.ref_name }}"
base: "${{ github.ref_name }}"
title: "Refresh notebook(s) for use case ${{ github.event.inputs.use_case }} for branch ${{ github.ref_name }}"
body: "Automatic PR with notebook(s) refresh of use case ${{ github.event.inputs.use_case }} \
for branch ${{ github.ref_name }}."
add-paths: |
use_case_examples/**/*.ipynb
# If the target branch is another branch, the current branch is automatically merged into it
- name: Push changes into the current branch
if: ${{ github.event.inputs.push_changes == 'true' && github.ref_name != 'main' && !(startsWith(github.ref_name , 'release/')) }}
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 #v5.0.1
with:
commit_message: "chore: refresh notebook(s) for use case ${{ github.event.inputs.use_case }}"
add_options: '-u'
file_pattern: 'use_case_examples/**/*.ipynb'
stop-runner-linux:
name: Stop EC2 runner
needs: [run-use-case-examples, start-runner-linux]
runs-on: ubuntu-20.04
if: ${{ always() && (needs.start-runner-linux.result != 'skipped') }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner python 38
uses: machulav/ec2-github-runner@1827d6ca7544d7044ddbd2e9360564651b463da2
if: ${{ always() && needs.start-runner-linux.outputs.ec2-instance-id-38 }}
with:
github-token: ${{ secrets.EC2_RUNNER_BOT_TOKEN }}
label: ${{ needs.start-runner-linux.outputs.label-38 }}
ec2-instance-id: ${{ needs.start-runner-linux.outputs.ec2-instance-id-38 }}
mode: stop
send-report:
if: ${{ always() }}
needs:
[
start-runner-linux,
run-use-case-examples,
stop-runner-linux,
]
name: Send Slack notification
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Prepare whole job status
if: ${{ always() }}
continue-on-error: true
env:
NEEDS_JSON: ${{ toJSON(needs) }}
run: |
echo "${NEEDS_JSON}" > /tmp/needs_context.json
JOB_STATUS=$(python3 ./script/actions_utils/actions_combine_status.py \
--needs_context_json /tmp/needs_context.json)
echo "JOB_STATUS=${JOB_STATUS}" >> "$GITHUB_ENV"
- name: Slack Notification
if: ${{ always() }}
continue-on-error: true
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990
env:
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png
SLACK_COLOR: ${{ env.JOB_STATUS || 'failure' }}
SLACK_MESSAGE: "Run of single use case '${{ github.event.inputs.use_case }}' finished with status ${{ env.JOB_STATUS || 'failure' }} \
(${{ env.ACTION_RUN_URL }})\n\
- start-runner-linux: ${{ needs.start-runner-linux.result || 'Did not run.'}}\n\n\
- run-use-case-examples: ${{ needs.run-use-case-examples.result || 'Did not run.' }}\n\n\
- stop-runner-linux: ${{ needs.stop-runner-linux.result || 'Did not run.'}}"
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}