-
Notifications
You must be signed in to change notification settings - Fork 0
303 lines (248 loc) · 8.96 KB
/
release.yaml
File metadata and controls
303 lines (248 loc) · 8.96 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# .github/workflows/release.yml
on:
workflow_call:
inputs:
name:
required: true
type: string
target:
required: true
type: string
additional_config:
type: string
required: false
default: ""
additional_profile:
type: string
required: false
default: ""
generated_model_path:
type: string
required: true
snakemake_dir:
type: string
required: false
default: "."
main_runner:
type: string
required: false
default: "aiinfn-lamarrsim-gpu"
model_prefix:
type: string
required: false
default: "trk"
secrets:
SECRETS_YAML:
required: true
jobs:
plan:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Notify of the release in the PR
uses: actions/github-script@v7
with:
script: |
const releaseUrl = `https://github.com/${{ github.repository }}/releases/tag/${{ inputs.name }}-${{ env.RELEASE_TIMESTAMP }}`;
const body = `
## :robot: A new training is being planned.
* Name: ${{ inputs.name }}
* Repository sub-dir: ${{ inputs.snakemake_dir }}
* Snakemake targets: ${{ inputs.target }}
* Selected runner: ${{ inputs.main_runner }}
At the end of the training, the models will be released and this PR will be notified again.
`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
train-and-validate:
runs-on: ${{ inputs.main_runner }}
timeout-minutes: 1500 # a bit more than one day
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore file timestamps
run: |
git log -1 --format="%at" -- notebooks/workflow/envs/lhcb.def
- name: Retrieve secrets
run: |
mkdir -p /tmp/artifacts
cat <<EOF > /tmp/artifacts/secrets.yaml
${{ secrets.SECRETS_YAML }}
EOF
- name: Snakemake workflow
uses: landerlini/apptainer-gha-runner/workflow@main
with:
workdir: ${{ inputs.snakemake_dir }}
target: ${{ inputs.target }}
report: report-${{ inputs.name }}
snakefile: workflow/Snakefile
config: |
secrets_file: /tmp/artifacts/secrets.yaml
${{ inputs.additional_config }}
profile: |
rerun-incomplete: True
keep-going: True
software-deployment-method: apptainer
local-storage-prefix: /tmp
apptainer-args: -B /home -B /cvmfs -B /tmp --nv --writable-tmpfs --no-mount /usr
keep-storage-local-copies: true
jobs: 1
cores: 8
default-resources:
mem_mb: 2000
millicpu: 1000
resources:
mem_mb: 64000
millicpu: 32000
gpu: 1
${{ inputs.additional_profile }}
- name: Upload raw model
uses: actions/upload-artifact@v4
with:
name: compiled_model.c
path: ${{ inputs.generated_model_path }}
compress-transpiled-c:
runs-on: ubuntu-latest
# container: harbor.cloud.infn.it/unpacked/aiinfn-gha-runner:latest
needs: train-and-validate
steps:
- name: Install missing libraries
run: |
sudo apt-get update
sudo apt-get install -y xz-utils
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: compiled_model.c
path: ./artifact
- name: Compress file
run: |
xz -9e -T0 -c -k "$(find ./artifact -type f -name '*.c' | head -n 1)" > compiled_model.c.xz
- name: Upload compressed model
uses: actions/upload-artifact@v4
with:
name: compiled_model.c.xz
path: ./compiled_model.c.xz
compile:
needs: train-and-validate
strategy:
matrix:
include:
- runner: ubuntu-latest
arch: x86_64_v2
compiler: centos7-gcc9-opt
container: /cvmfs/lhcb.cern.ch/containers/os-base/centos7-devel/prod/amd64
- runner: ubuntu-latest
arch: x86_64_v2
compiler: el9-gcc13-opt
container: /cvmfs/lhcb.cern.ch/containers/os-base/alma9-devel/prod/amd64/
- runner: ubuntu-latest
arch: x86_64_v2
compiler: el9-gcc13-dbg
container: /cvmfs/lhcb.cern.ch/containers/os-base/alma9-devel/prod/amd64/
- runner: ubuntu-24.04-arm
arch: armv8.1_a
compiler: el9-gcc13-opt
container: /cvmfs/lhcb.cern.ch/containers/os-base/alma9-devel/prod/arm64v8/
runs-on: ${{ matrix.runner }}
steps:
- name: Mount CVMFS
uses: cvmfs-contrib/github-action-cvmfs@v4
- name: Build apptainer
run: |
git clone https://github.com/apptainer/apptainer.git
cd apptainer
git checkout v1.4.1
./mconfig --with-suid
make -C builddir
sudo make -C builddir install
- name: Download transpiled model (uncompressed)
uses: actions/download-artifact@v4
with:
name: compiled_model.c
path: ./artifact
- name: Compile ${{ inputs.name }} for ${{ matrix.arch }}-${{ matrix.compiler }}
run: |
cat <<EOF > compile_cmd.sh
source /cvmfs/lhcb.cern.ch/lib/LbEnv -c ${{ matrix.arch }}-${{ matrix.compiler }}
mkdir -p build
gcc artifact/compiled_model.c \
-O3 \
-lm \
--shared \
-fPIC \
-std=c99 \
-o build/${{ inputs.model_prefix }}-${{ matrix.arch }}-${{ matrix.compiler }}.so
EOF
apptainer exec -B/home -B/cvmfs -B/tmp \
${{ matrix.container }} \
/bin/bash compile_cmd.sh
- name: Upload ${{ inputs.model_prefix }}-${{ matrix.arch }}-${{ matrix.compiler }}
uses: actions/upload-artifact@v4
with:
path: build/${{ inputs.model_prefix }}-${{ matrix.arch }}-${{ matrix.compiler }}.so
name: ${{ matrix.arch }}-${{ matrix.compiler }}
release:
runs-on: ubuntu-latest
needs: compile
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
path: ./artifact
- name: Download artifact
run: |
mkdir -p artifact/test
echo "test" > artifact/test/test.so
- name: Install GitHub CLI
run: sudo apt-get update && sudo apt-get install -y gh
- name: Fetch latest merged PR description
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "RELEASE_TIMESTAMP=$(date +'%Y-%m-%dT%Hh%Mm%S')" >> $GITHUB_ENV
gh pr list --head ${{ github.head_ref }} --limit 1 --json number,body \
--jq '.[0].body' > pr_description.md
- name: List artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
find artifact/
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ncipollo/release-action@v1
with:
tag: ${{ inputs.name }}-${{ env.RELEASE_TIMESTAMP }}
name: "Models ${{ github.base_ref }} trained for ${{ inputs.name }}-${{ env.RELEASE_TIMESTAMP }}"
bodyFile: pr_description.md
artifacts: artifact/*/*.so,artifact/*/*.html,artifact/*/*.xz,artifact/*/*.zip
artifactContentType: raw
- name: Notify of the release in the PR
uses: actions/github-script@v7
with:
script: |
const releaseUrl = `https://github.com/${{ github.repository }}/releases/tag/${{ inputs.name }}-${{ env.RELEASE_TIMESTAMP }}`;
const body = `
## :rocket: Models for ${{ inputs.name }} were released
You can review the models developed in this PR in [Release ${{ inputs.name }}-${{ env.RELEASE_TIMESTAMP }}](${releaseUrl})
`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});