-
Notifications
You must be signed in to change notification settings - Fork 5
165 lines (145 loc) · 5.86 KB
/
upload-ersilia-pack.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
name: Upload Ersilia Pack Dockerized Model
on:
workflow_call:
jobs:
build-ersilia-pack-image:
if: ${{ github.repository != 'ersilia-os/eos-template' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- run: git lfs pull
# 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
# Install ersilia-pack, requests, and ersilia to test the built image with ersilia CLI
- name: Setup Python for Ersilia Pack
id: setupPythonForErsiliaPack
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
with:
python-version: '3.10'
- name: Install ersilia-pack and generate the right Dockerfile
env:
REPO_NAME: ${{ github.event.repository.name }}
run: |
python -m pip install git+https://github.com/ersilia-os/ersilia-pack.git
python -m pip install requests
python -m pip install git+https://github.com/ersilia-os/ersilia.git
python .github/scripts/resolve_dockerfile.py $REPO_NAME
- name: Build only AMD64 Image for Testing
id: buildForTestErsiliaPack
uses: docker/[email protected]
with:
context: ../ # We need to go back to the root directory to find the Dockerfile and copy the model repository
load: true
tags: ersiliaos/${{ github.event.repository.name }}:latest
- name: Test built image
id: testBuiltImageErsiliaPack
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
if: steps.buildForTestErsiliaPack.outcome == 'success'
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.testBuiltImageErsiliaPack.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.testBuiltImageErsiliaPack.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.testBuiltImageErsiliaPack.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