generated from ersilia-os/eos-template
-
Notifications
You must be signed in to change notification settings - Fork 3
185 lines (163 loc) · 6.36 KB
/
upload-bentoml.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
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
name: Upload BentoML Dockerized Model with or without Multi-stage Conda Pack
on:
workflow_call:
inputs:
version:
required: true
type: string
jobs:
build-bentoml-image:
if: ${{ github.repository != 'ersilia-os/eos-template' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if we can use this workflow
run: |
if [[ -f install.yml ]]; then
echo "This workflow is not supported for this repository"
exit 1
fi
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
# log in to dockerhub
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# This might stop working in the future, so we need to keep an eye on it
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
- name: Setup conda
id: setupConda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.10.10"
- name: Install dependencies in Conda environment
id: installDependenciesInConda
run: |
conda install git-lfs -c conda-forge
git-lfs install
conda install gh -c conda-forge
python -m pip install git+https://github.com/ersilia-os/ersilia.git
- name: Generate the Dockerfile
id: generateDockerfile
env:
REPO_NAME: ${{ github.event.repository.name }}
VERSION: ${{ inputs.version}}
run: |
wget https://raw.githubusercontent.com/ersilia-os/ersilia/master/.github/scripts/place_a_dockerfile_in_current_eos_repo.py
python -m pip install requests
python place_a_dockerfile_in_current_eos_repo.py $REPO_NAME $VERSION
rm place_a_dockerfile_in_current_eos_repo.py
# We cannot tag it as anything other than latest because
# ersilia cli only looks for the 'latest' tag
- name: Build only AMD64 Image for Testing
id: buildForTest
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ersiliaos/${{ github.event.repository.name }}:latest
# TODO This is very hacky, maybe we want to use the ersilia test command in the future for this
- name: Test built image
id: testBuiltImage
env:
PULL_IMAGE: n
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
run: |
ersilia -v fetch ${{ github.event.repository.name }} --from_dockerhub
ersilia -v serve ${{ github.event.repository.name }} --track #Added --track here
ersilia example -n 1 -f input.csv --predefined
ersilia -v run -i "input.csv" -o "output.csv"
ersilia close
output=$(python .github/scripts/verify_model_outcome.py output.csv)
if echo "$output" | grep -q "All outcomes are null"; then
echo "Error in model outcome, aborting build"
exit 1
fi
- name: Upload output.csv
if: always()
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb #pin v3.1.1
with:
name: model-output
retention-days: 14
path: output.csv
- run: rm output.csv
# If test failed, we tag the image as dev
- name: Tag Dev image
id: tagDevImage
if: steps.testBuiltImage.outcome == 'failure'
run: |
docker tag ersiliaos/${{ github.event.repository.name }}:latest ersiliaos/${{ github.event.repository.name }}:dev
docker push ersiliaos/${{ github.event.repository.name }}:dev
- name: Create a Test issue
if: steps.testBuiltImage.outcome == 'failure'
uses: actions-ecosystem/action-create-issue@b63bc2bbacb6a838dfe4a9f70da6665ae0962a49
id: createFailureIssue
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
title: Failed model build
body: |
The model build failed. Please check the logs and fix the issue.
A dev image has been pushed to DockerHub for reference.
labels: |
bug
# If test succeeds we tag the image with timestamp and latest
- name: Get date
id: get-date
env:
DATE: ${{ github.run_started_at }}
run: |
# Keep only the date part
DATE=$(echo $DATE | cut -d 'T' -f 1)
echo "date=$DATE" >> $GITHUB_OUTPUT
- name: Build and push
id: buildMultiple
if: steps.testBuiltImage.outcome == 'success'
continue-on-error: true
uses: docker/[email protected]
timeout-minutes: 45
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
ersiliaos/${{ github.event.repository.name }}:latest
ersiliaos/${{ github.event.repository.name }}:${{ steps.get-date.outputs.date }}
- name: Set build failure output
id: buildCheck
run: |
if [[ "${{ steps.buildMultiple.outcome }}" == "failure" ]]; then
echo "::set-output name=failed::true"
echo "AMD64" > arch.txt
else
echo "::set-output name=failed::false"
echo "AMD64,ARM64" > arch.txt
fi
- name: Upload arch.txt
uses: actions/upload-artifact@v4
with:
name: arch
path: arch.txt