-
Notifications
You must be signed in to change notification settings - Fork 1
340 lines (300 loc) · 12.7 KB
/
Copy pathcontainer-physicsnemo.yml
File metadata and controls
340 lines (300 loc) · 12.7 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# SPDX-FileCopyrightText: 2026 Samudra Authors
#
# SPDX-License-Identifier: Apache-2.0
# Build the PhysicsNeMo-based container on PRs; on main/manual runs, also publish
# x86_64 and arm64 images, run x86_64 CPU/GPU container tests, and run arm64
# CPU-only container tests on a non-GPU ARM runner.
name: Container PhysicsNeMo 26.05
on:
push:
branches:
- main
pull_request:
branches:
- "**"
workflow_dispatch:
permissions:
id-token: write
contents: read
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
ec2-build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: Open-Athena/ec2-gha/.github/workflows/runner.yml@v2
with:
aws_region: us-east-1
ec2_instance_type: m7i.xlarge
# Ubuntu 24.04 LTS amd64 hvm ebs-gp3 in us-east-1, Canonical owner 099720109477.
# To refresh, run:
# aws ec2 describe-images --region us-east-1 --owners 099720109477 --filters \
# 'Name=name,Values=ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*' \
# 'Name=architecture,Values=x86_64' 'Name=virtualization-type,Values=hvm' \
# 'Name=root-device-type,Values=ebs' 'Name=state,Values=available' \
# --query 'reverse(sort_by(Images, &CreationDate))[:1].ImageId' --output text
ec2_image_id: ami-04b70fa74e45c3917
ec2_root_device_size: 200 # (GBs) local x86_64 image build needs substantial headroom
aws_tags: '[{"Key": "project", "Value": "fomo"}]'
secrets:
GH_SA_TOKEN: ${{ secrets.GH_SA_TOKEN }}
build-and-smoke:
needs: ec2-build
runs-on: ${{ needs.ec2-build.outputs.id }}
env:
LOCAL_IMAGE_TAG: ocean-emulator:physicsnemo-26.05-${{ github.sha }}
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Confirm x86_64 runner
run: |
arch="$(uname -m)"
echo "runner arch=${arch}"
test "${arch}" = "x86_64"
- name: Install Docker
run: |
set -euo pipefail
if ! command -v docker >/dev/null 2>&1 || ! docker buildx version >/dev/null 2>&1; then
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-buildx
fi
sudo systemctl enable --now docker || sudo service docker start
sudo chmod 666 /var/run/docker.sock
docker version
docker buildx version
- name: Build container
run: |
BUILDKIT_PROGRESS=plain \
IMAGE_TAG="${LOCAL_IMAGE_TAG}" \
DOCKERFILE=containers/Dockerfile.physicsnemo-26.05 \
BUILD_APPTAINER=0 \
bash scripts/container/build_physicsnemo_26_05.sh
- name: Log in to GHCR
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish x86_64 image
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
run: |
set -euo pipefail
owner_lower="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
ghcr_image="ghcr.io/${owner_lower}/ocean-emulator-physicsnemo"
sha_tag="${ghcr_image}:26.05-${GITHUB_SHA}"
arch_sha_tag="${ghcr_image}:26.05-x86_64-${GITHUB_SHA}"
docker tag "${LOCAL_IMAGE_TAG}" "${sha_tag}"
docker tag "${LOCAL_IMAGE_TAG}" "${arch_sha_tag}"
docker push "${sha_tag}"
docker push "${arch_sha_tag}"
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
ref_tag="${ghcr_image}:26.05-manual-${GITHUB_REF_NAME//\//-}"
arch_ref_tag="${ghcr_image}:26.05-x86_64-manual-${GITHUB_REF_NAME//\//-}"
docker tag "${LOCAL_IMAGE_TAG}" "${ref_tag}"
docker tag "${LOCAL_IMAGE_TAG}" "${arch_ref_tag}"
docker push "${ref_tag}"
docker push "${arch_ref_tag}"
fi
if [ "${GITHUB_EVENT_NAME}" = "push" ] && [ "${GITHUB_REF}" = "refs/heads/main" ]; then
latest_tag="${ghcr_image}:26.05-latest"
arch_latest_tag="${ghcr_image}:26.05-x86_64-latest"
docker tag "${LOCAL_IMAGE_TAG}" "${latest_tag}"
docker tag "${LOCAL_IMAGE_TAG}" "${arch_latest_tag}"
docker push "${latest_tag}"
docker push "${arch_latest_tag}"
fi
ec2:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
needs: build-and-smoke
uses: Open-Athena/ec2-gha/.github/workflows/runner.yml@v2
with:
ec2_instance_type: g6.xlarge
ec2_image_id: ami-0365bff494b18bf93 # Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.7 (Ubuntu 22.04) in oa-ci-dev
ec2_root_device_size: 200 # large image pull + test data/cache need substantial headroom
aws_tags: '[{"Key": "project", "Value": "fomo"}]'
secrets:
GH_SA_TOKEN: ${{ secrets.GH_SA_TOKEN }}
ec2-arm:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
uses: Open-Athena/ec2-gha/.github/workflows/runner.yml@v2
with:
aws_region: us-east-1
ec2_instance_type: m7g.xlarge
# Ubuntu 24.04 LTS arm64 hvm ebs-gp3 in us-east-1, Canonical owner 099720109477.
# To refresh, run:
# aws ec2 describe-images --region us-east-1 --owners 099720109477 --filters \
# 'Name=name,Values=ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-*' \
# 'Name=architecture,Values=arm64' 'Name=virtualization-type,Values=hvm' \
# 'Name=root-device-type,Values=ebs' 'Name=state,Values=available' \
# --query 'reverse(sort_by(Images, &CreationDate))[:1].ImageId' --output text
ec2_image_id: ami-02c57ce16e9a8e906
ec2_root_device_size: 200 # local arm64 image build plus test data/cache need substantial headroom
aws_tags: '[{"Key": "project", "Value": "fomo"}]'
secrets:
GH_SA_TOKEN: ${{ secrets.GH_SA_TOKEN }}
test-container-cpu-gpu:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
needs: [build-and-smoke, ec2]
runs-on: ${{ needs.ec2.outputs.id }}
steps:
- name: Check out code
uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
- name: Cache test data
uses: actions/cache@v3
with:
path: .data_cache/
key: ${{ runner.os }}-test-data-${{ hashFiles('tests/conftest.py', 'configs/test/*.yaml') }}
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Show disk before pull
run: |
df -h
docker system df || true
- name: Pull published image
run: |
set -euo pipefail
owner_lower="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
image="ghcr.io/${owner_lower}/ocean-emulator-physicsnemo:26.05-${GITHUB_SHA}"
docker pull "${image}"
echo "TEST_IMAGE=${image}" >> "${GITHUB_ENV}"
- name: Run CPU tests in container
timeout-minutes: 90
run: |
docker run --rm \
--ipc=host \
-v "${GITHUB_WORKSPACE}/.data_cache:/workspace/.data_cache" \
--workdir /workspace \
--entrypoint bash \
"${TEST_IMAGE}" -lc '
set -euo pipefail
. .venv/bin/activate
python -m pytest -p no:zarr -n 2 -v -m "not manual and not cuda" --durations=20 --durations-min=1.0
'
- name: Run GPU tests in container
timeout-minutes: 90
run: |
docker run --rm --gpus all \
--ipc=host \
-v "${GITHUB_WORKSPACE}/.data_cache:/workspace/.data_cache" \
--workdir /workspace \
--entrypoint bash \
"${TEST_IMAGE}" -lc '
set -euo pipefail
. .venv/bin/activate
python -m pytest -p no:zarr -v -m "not manual and cuda" -x --durations=20 --durations-min=1.0
'
build-test-publish-arm64:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
needs: ec2-arm
runs-on: ${{ needs.ec2-arm.outputs.id }}
env:
LOCAL_ARM64_IMAGE_TAG: ocean-emulator:physicsnemo-26.05-arm64-${{ github.sha }}
steps:
- name: Check out code
uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
- name: Confirm arm64 runner
run: |
arch="$(uname -m)"
echo "runner arch=${arch}"
test "${arch}" = "aarch64"
- name: Install Docker
run: |
set -euo pipefail
if ! command -v docker >/dev/null 2>&1 || ! docker buildx version >/dev/null 2>&1; then
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-buildx
fi
sudo systemctl enable --now docker || sudo service docker start
sudo chmod 666 /var/run/docker.sock
docker version
docker buildx version
- name: Cache test data
uses: actions/cache@v3
with:
path: .data_cache/
key: ${{ runner.os }}-${{ runner.arch }}-test-data-${{ hashFiles('tests/conftest.py', 'configs/test/*.yaml') }}
- name: Show disk before build
run: |
df -h
docker system df || true
- name: Build arm64 container
run: |
BUILDKIT_PROGRESS=plain \
IMAGE_TAG="${LOCAL_ARM64_IMAGE_TAG}" \
DOCKERFILE=containers/Dockerfile.physicsnemo-26.05 \
BUILD_APPTAINER=0 \
bash scripts/container/build_physicsnemo_26_05.sh
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish arm64 image
run: |
set -euo pipefail
owner_lower="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
ghcr_image="ghcr.io/${owner_lower}/ocean-emulator-physicsnemo"
sha_tag="${ghcr_image}:26.05-arm64-${GITHUB_SHA}"
docker tag "${LOCAL_ARM64_IMAGE_TAG}" "${sha_tag}"
docker push "${sha_tag}"
echo "TEST_ARM64_IMAGE=${sha_tag}" >> "${GITHUB_ENV}"
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
ref_tag="${ghcr_image}:26.05-arm64-manual-${GITHUB_REF_NAME//\//-}"
docker tag "${LOCAL_ARM64_IMAGE_TAG}" "${ref_tag}"
docker push "${ref_tag}"
fi
if [ "${GITHUB_EVENT_NAME}" = "push" ] && [ "${GITHUB_REF}" = "refs/heads/main" ]; then
latest_tag="${ghcr_image}:26.05-arm64-latest"
docker tag "${LOCAL_ARM64_IMAGE_TAG}" "${latest_tag}"
docker push "${latest_tag}"
fi
- name: Pull published arm64 image
run: |
set -euo pipefail
docker pull "${TEST_ARM64_IMAGE}"
- name: Run CPU tests in arm64 container
timeout-minutes: 90
run: |
docker run --rm \
--ipc=host \
-v "${GITHUB_WORKSPACE}/.data_cache:/workspace/.data_cache" \
--workdir /workspace \
--entrypoint bash \
"${TEST_ARM64_IMAGE}" -lc '
set -euo pipefail
. .venv/bin/activate
# The smaller arm64 runner is more prone to losing the GitHub runner
# process under xdist CPU-test load after the local image build.
python -m pytest -p no:zarr -v -m "not manual and not cuda" --durations=20 --durations-min=1.0
'
report-container-test-status:
if: always()
needs:
- ec2-build
- build-and-smoke
- ec2
- ec2-arm
- test-container-cpu-gpu
- build-test-publish-arm64
runs-on: ubuntu-latest
steps:
- name: Check job results
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
- name: Fail if container build did not run
if: needs['build-and-smoke'].result == 'skipped'
run: |
echo "AWS-backed container tests did not run automatically."
echo "Run this workflow manually from the GitHub Actions UI once the code has been reviewed."
exit 1