Skip to content

Commit a0561d1

Browse files
danielpcoxclaude
andauthored
Add GitHub Actions CI (#4)
* Add GitHub Actions CI - Test on Python 3.11, 3.12, 3.13 (CPU) - Build verification with wheel content check - Per-test 60s timeout to catch hangs - Uses uv for fast dependency resolution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix CI: skip local-only dev dependency group The [dependency-groups] dev includes jax-mps with a local path source (../jax-mps) that doesn't exist in CI. Use --no-dev to skip the dependency group while still installing [project.optional-dependencies] dev extras (pytest, torch). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Remove jax-mps dependency — users install platform backends themselves Remove [mps] optional extra, [tool.uv.sources] local path, and jax-mps from dev dependency group. Platform-specific JAX backends (MPS, CUDA, TPU) are the user's responsibility, with CPU as the default fallback. Also reverts the --no-dev CI workaround since the local path source was the only reason it was needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix float32 cosine similarity bound check in test Cosine similarity can exceed 1.0 by ~1e-7 due to float32 rounding. Add tolerance to bound checks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add PyPI publish workflow using trusted publishing Triggers on GitHub releases. Builds the package, verifies no test files in the wheel, then publishes to PyPI via OpenID Connect (no API tokens needed). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Remove environment from publish workflow to match PyPI config Trusted publisher was configured without an environment name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ff4706e commit a0561d1

6 files changed

Lines changed: 102 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.11", "3.12", "3.13"]
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: astral-sh/setup-uv@v5
19+
with:
20+
enable-cache: true
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
run: uv python install ${{ matrix.python-version }}
24+
25+
- name: Install dependencies
26+
run: uv sync --extra dev
27+
28+
- name: Run tests
29+
run: uv run pytest irtk/tests/ -x -q --timeout=60
30+
env:
31+
JAX_PLATFORMS: cpu
32+
33+
build:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- uses: astral-sh/setup-uv@v5
39+
with:
40+
enable-cache: true
41+
42+
- name: Build package
43+
run: uv build
44+
45+
- name: Check wheel contents
46+
run: python3 -m zipfile -l dist/*.whl | grep -c "test_" | xargs -I{} test {} -eq 0

.github/workflows/publish.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- uses: astral-sh/setup-uv@v5
14+
with:
15+
enable-cache: true
16+
17+
- name: Build package
18+
run: uv build
19+
20+
- name: Check wheel contents
21+
run: python3 -m zipfile -l dist/*.whl | grep -c "test_" | xargs -I{} test {} -eq 0
22+
23+
- uses: actions/upload-artifact@v4
24+
with:
25+
name: dist
26+
path: dist/
27+
28+
publish:
29+
needs: build
30+
runs-on: ubuntu-latest
31+
permissions:
32+
id-token: write
33+
steps:
34+
- uses: actions/download-artifact@v4
35+
with:
36+
name: dist
37+
path: dist/
38+
39+
- uses: pypa/gh-action-pypi-publish@release/v1

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ Initially vibe-coded by Opus, so YMMV. PRs welcome.
1010
pip install irtk-jax
1111
```
1212

13-
For Apple Silicon GPU acceleration via [jax-mps](https://github.com/danielpcox/jax-mps):
14-
15-
```bash
16-
pip install irtk-jax[mps]
17-
```
18-
1913
### Development setup
2014

2115
```bash

irtk/tests/test_model_internal_consistency.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_logit_lens_values(model_and_tokens):
4343
model, tokens = model_and_tokens
4444
result = logit_lens_consistency(model, tokens, position=-1)
4545
for p in result["per_layer"]:
46-
assert -1.0 <= p["logit_cosine"] <= 1.0
46+
assert -1.0 - 1e-6 <= p["logit_cosine"] <= 1.0 + 1e-6
4747
assert result["per_layer"][-1]["agrees_with_final"] is True
4848

4949

@@ -74,7 +74,7 @@ def test_orthogonality_structure(model_and_tokens):
7474
def test_orthogonality_values(model_and_tokens):
7575
model, tokens = model_and_tokens
7676
result = component_orthogonality(model, tokens, layer=0, position=-1)
77-
assert -1.0 <= result["cosine"] <= 1.0
77+
assert -1.0 - 1e-6 <= result["cosine"] <= 1.0 + 1e-6
7878
assert 0 <= result["orthogonality"] <= 1.0
7979

8080

pyproject.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ dev = [
3535
"pytest>=7.0",
3636
"torch>=2.0",
3737
]
38-
mps = [
39-
"jax-mps",
40-
]
41-
4238
[tool.hatch.build.targets.wheel]
4339
packages = ["irtk"]
4440
exclude = ["irtk/tests"]
@@ -49,12 +45,9 @@ exclude = ["notebooks", "irtk/tests"]
4945
[tool.pytest.ini_options]
5046
testpaths = ["irtk/tests"]
5147

52-
[tool.uv.sources]
53-
jax-mps = { path = "../jax-mps", editable = true }
54-
5548
[dependency-groups]
5649
dev = [
57-
"jax-mps",
5850
"jupyterlab>=4.5.5",
51+
"pytest-timeout>=2.2.0",
5952
"pytest-xdist>=3.8.0",
6053
]

uv.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)