generated from ersilia-os/eos-template
-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (103 loc) · 4.11 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
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
# 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
continue-on-error: true # Allow this to fail;
uses: docker/build-push-action@v6.7.0
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
if: steps.buildForTestErsiliaPack.outcome == 'success'
continue-on-error: true # Allow this to fail
run: |
ersilia -v fetch ${{ github.event.repository.name }} --from_dockerhub
ersilia -v serve ${{ github.event.repository.name }}
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
rm output.csv
- name: Build and push
id: buildMultiple
continue-on-error: true
uses: docker/build-push-action@v6.7.0
timeout-minutes: 45
with:
context: ../
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ersiliaos/${{ github.event.repository.name }}:latest
- 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