Skip to content

Commit 23806df

Browse files
jamesbornholtdnnanuti
andauthored
Build macOS wheels and integration tests (#197)
* Build macOS wheels and integration tests This is pretty simple, mostly just adding macos-13 (x86) and macos-14 (arm64) runners to the matrix. We also need to explicitly disable MPS for PyTorch to run correctly on the memory-limited GHA runners. Signed-off-by: James Bornholt <[email protected]> * Update Rust setup actions * Update python setup action and temporarily disable macos-14 * Enable macos-14 arm64 --------- Signed-off-by: James Bornholt <[email protected]> Co-authored-by: dnnanuti <[email protected]>
1 parent 640a154 commit 23806df

File tree

6 files changed

+50
-43
lines changed

6 files changed

+50
-43
lines changed

.github/workflows/ci-integration-main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Integration tests (Main)
22

33
on:
44
push:
5-
branches: [ "main", "feature/*" ]
5+
branches: [ "main", "feature/*", "workflow/*" ]
66
merge_group:
77
types: [ "checks_requested" ]
88

.github/workflows/python-checks.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Set up stable Rust
26-
uses: actions-rs/toolchain@v1
27-
with:
28-
toolchain: stable
29-
override: true
26+
uses: dtolnay/rust-toolchain@stable
3027

3128
- name: Cargo cache
3229
uses: actions/cache@v3
3330
with:
3431
path: |
35-
~/.cargo/bin/
3632
~/.cargo/registry/index/
3733
~/.cargo/registry/cache/
3834
~/.cargo/git/db/
@@ -75,16 +71,12 @@ jobs:
7571
uses: actions/checkout@v4
7672

7773
- name: Set up stable Rust
78-
uses: actions-rs/toolchain@v1
79-
with:
80-
toolchain: stable
81-
override: true
74+
uses: dtolnay/rust-toolchain@stable
8275

8376
- name: Cargo cache
8477
uses: actions/cache@v3
8578
with:
8679
path: |
87-
~/.cargo/bin/
8880
~/.cargo/registry/index/
8981
~/.cargo/registry/cache/
9082
~/.cargo/git/db/

.github/workflows/python-integration.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ env:
1919
jobs:
2020
integration-test:
2121
name: Integration tests
22-
runs-on: ubuntu-22.04
22+
runs-on: ${{ matrix.runner }}
2323
environment: ${{ inputs.environment }}
2424
strategy:
2525
fail-fast: false
2626
matrix:
27+
runner: [ubuntu-22.04, macos-13]
2728
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
2829
test-run:
2930
- name: "S3"
@@ -53,17 +54,13 @@ jobs:
5354
aws-region: ${{ vars.S3_REGION }}
5455

5556
- name: Set up stable Rust
56-
uses: actions-rs/toolchain@v1
57-
with:
58-
toolchain: stable
59-
override: true
57+
uses: dtolnay/rust-toolchain@stable
6058

6159
- name: Restore Cargo cache
6260
id: restore-cargo-cache
6361
uses: actions/cache/restore@v3
6462
with:
6563
path: |
66-
~/.cargo/bin/
6764
~/.cargo/registry/index/
6865
~/.cargo/registry/cache/
6966
~/.cargo/git/db/
@@ -114,7 +111,6 @@ jobs:
114111
if: inputs.environment != 'integration-tests'
115112
with:
116113
path: |
117-
~/.cargo/bin/
118114
~/.cargo/registry/index/
119115
~/.cargo/registry/cache/
120116
~/.cargo/git/db/

.github/workflows/rust-checks.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ jobs:
2828
uses: actions/checkout@v4
2929

3030
- name: Set up stable Rust
31-
uses: actions-rs/toolchain@v1
32-
with:
33-
toolchain: stable
34-
override: true
35-
submodules: true
31+
uses: dtolnay/rust-toolchain@stable
3632

3733
- name: Run cargo deny
3834
uses: EmbarkStudios/cargo-deny-action@v1
@@ -48,17 +44,12 @@ jobs:
4844
uses: actions/checkout@v4
4945

5046
- name: Set up stable Rust
51-
uses: actions-rs/toolchain@v1
52-
with:
53-
toolchain: stable
54-
components: clippy
55-
override: true
47+
uses: dtolnay/rust-toolchain@stable
5648

5749
- name: Cargo cache
5850
uses: actions/cache@v3
5951
with:
6052
path: |
61-
~/.cargo/bin/
6253
~/.cargo/registry/index/
6354
~/.cargo/registry/cache/
6455
~/.cargo/git/db/
@@ -69,18 +60,17 @@ jobs:
6960
run: cargo clippy --all-targets --all-features --manifest-path s3torchconnectorclient/Cargo.toml
7061

7162
tests:
72-
runs-on: ubuntu-22.04
63+
runs-on: ${{ matrix.runner }}
7364
name: Rust tests
65+
strategy:
66+
matrix:
67+
runner: [ubuntu-22.04, macos-13]
7468
steps:
7569
- name: Checkout code
7670
uses: actions/checkout@v4
7771

7872
- name: Set up stable Rust
79-
uses: actions-rs/toolchain@v1
80-
with:
81-
toolchain: stable
82-
override: true
83-
submodules: true
73+
uses: dtolnay/rust-toolchain@stable
8474

8575
- name: Build Rust tests
8676
run: cargo test --no-default-features --no-run --manifest-path s3torchconnectorclient/Cargo.toml

.github/workflows/wheels.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,33 @@ jobs:
1919
uses: ./.github/workflows/generate_third_party_licenses.yml
2020

2121
build_wheels:
22-
name: Build wheels for ${{ matrix.build_prefix }} - ${{ matrix.builder.arch }}
22+
name: Wheels for ${{ matrix.python }} - ${{ matrix.builder.kind }} - ${{ matrix.builder.arch }}
2323
runs-on: ${{ matrix.builder.runner }}
2424
needs: generate_third_party_licenses
2525
strategy:
2626
matrix:
27-
build_prefix:
27+
python:
2828
- cp38
2929
- cp39
3030
- cp310
3131
- cp311
3232
- cp312
3333
builder:
3434
- runner: codebuild-${{ vars.CODEBUILD_PROJECT_NAME }}-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-large
35+
kind: manylinux
3536
arch: x86_64
3637
- runner: codebuild-${{ vars.CODEBUILD_PROJECT_NAME }}-${{ github.run_id }}-${{ github.run_attempt }}-arm-3.0-large
38+
kind: manylinux
3739
arch: aarch64
3840
# - runner: ubuntu-20.04
41+
# kind: manylinux
3942
# arch: x86_64
43+
- runner: macos-13
44+
kind: macosx
45+
arch: x86_64
46+
- runner: macos-14
47+
kind: macosx
48+
arch: arm64
4049
permissions:
4150
id-token: write
4251
contents: read
@@ -62,16 +71,29 @@ jobs:
6271
run: |
6372
mv NOTICE_DEFAULT THIRD-PARTY-LICENSES
6473
74+
# actions/setup-python requires /Users/runner/hostedtoolcache to exist to work properly
75+
# with macosx due to fixed shared library path
76+
# https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#macos
77+
- name: Create hostedtoolcache dir for macosx
78+
if: ${{ matrix.builder.kind == 'macosx' }}
79+
run: |
80+
mkdir -p /Users/runner/hostedtoolcache
81+
6582
# actions/setup-python doesn't yet support ARM
6683
# https://github.com/actions/setup-python/issues/678
67-
- if: ${{ matrix.builder.arch != 'aarch64' }}
68-
uses: actions/setup-python@v4
84+
- name: Setup Python
85+
if: ${{ matrix.builder.arch != 'aarch64' }}
86+
uses: actions/setup-python@v5
6987
with:
70-
python-version: "3.11"
88+
python-version: "3.12"
7189

7290
- name: Install pipx
7391
run: |
74-
python -m pip install --upgrade pipx
92+
which python
93+
which pip
94+
python -m pip install --upgrade pip
95+
python -m pip install --upgrade pipx
96+
python -m pipx ensurepath
7597
7698
# Run cibuildwheel manually, as the current runner uses setup-python
7799
# https://github.com/pypa/cibuildwheel/issues/1623
@@ -80,7 +102,7 @@ jobs:
80102
cibuildwheel
81103
"s3torchconnectorclient"
82104
--output-dir "wheelhouse"
83-
--only "${{ matrix.build_prefix }}-manylinux_${{ matrix.builder.arch }}"
105+
--only "${{ matrix.python }}-${{ matrix.builder.kind }}_${{ matrix.builder.arch }}"
84106
2>&1
85107
shell: bash
86108

s3torchconnector/tst/e2e/test_e2e_s3_lightning_checkpoint.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
from models.lightning_transformer import LightningTransformer, L
2323

2424

25+
LIGHTNING_ACCELERATOR = "cpu"
26+
27+
2528
def test_save_and_load_checkpoint(checkpoint_directory):
2629
tensor = torch.rand(3, 10, 10)
2730
s3_lightning_checkpoint = S3LightningCheckpoint(region=checkpoint_directory.region)
@@ -77,7 +80,7 @@ def test_load_trained_checkpoint(checkpoint_directory):
7780
dataset = WikiText2(data_dir=Path(f"/tmp/data/{nonce}"))
7881
dataloader = DataLoader(dataset, num_workers=3)
7982
model = LightningTransformer(vocab_size=dataset.vocab_size)
80-
trainer = L.Trainer(fast_dev_run=2)
83+
trainer = L.Trainer(accelerator=LIGHTNING_ACCELERATOR, fast_dev_run=2)
8184
trainer.fit(model=model, train_dataloaders=dataloader)
8285
checkpoint_name = "lightning_module_training_checkpoint.pt"
8386
s3_uri = f"{checkpoint_directory.s3_uri}{checkpoint_name}"
@@ -96,6 +99,7 @@ def test_compatibility_with_trainer_plugins(checkpoint_directory):
9699
s3_lightning_checkpoint = S3LightningCheckpoint(region=checkpoint_directory.region)
97100
_verify_user_agent(s3_lightning_checkpoint)
98101
trainer = L.Trainer(
102+
accelerator=LIGHTNING_ACCELERATOR,
99103
default_root_dir=checkpoint_directory.s3_uri,
100104
plugins=[s3_lightning_checkpoint],
101105
max_epochs=1,
@@ -130,6 +134,7 @@ def test_compatibility_with_checkpoint_callback(checkpoint_directory):
130134
enable_version_counter=True,
131135
)
132136
trainer = L.Trainer(
137+
accelerator=LIGHTNING_ACCELERATOR,
133138
plugins=[s3_lightning_checkpoint],
134139
callbacks=[checkpoint_callback],
135140
min_epochs=4,
@@ -163,6 +168,7 @@ def test_compatibility_with_async_checkpoint_io(checkpoint_directory):
163168
async_s3_lightning_checkpoint = AsyncCheckpointIO(s3_lightning_checkpoint)
164169

165170
trainer = L.Trainer(
171+
accelerator=LIGHTNING_ACCELERATOR,
166172
default_root_dir=checkpoint_directory.s3_uri,
167173
plugins=[async_s3_lightning_checkpoint],
168174
min_epochs=4,
@@ -189,6 +195,7 @@ def test_compatibility_with_lightning_checkpoint_load(checkpoint_directory):
189195
model = LightningTransformer(vocab_size=dataset.vocab_size)
190196
s3_lightning_checkpoint = S3LightningCheckpoint(region=checkpoint_directory.region)
191197
trainer = L.Trainer(
198+
accelerator=LIGHTNING_ACCELERATOR,
192199
default_root_dir=checkpoint_directory.s3_uri,
193200
plugins=[s3_lightning_checkpoint],
194201
max_epochs=1,

0 commit comments

Comments
 (0)