Skip to content

Commit eee0ae3

Browse files
Fix CI
1 parent 22a5cf1 commit eee0ae3

4 files changed

Lines changed: 1505 additions & 479 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@ name: Python package
22

33
on: [push]
44

5+
env:
6+
UV_LINK_MODE: "symlink"
7+
58
jobs:
69
build:
710
runs-on: ubuntu-latest
811
strategy:
912
matrix:
1013
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
11-
14+
include:
15+
- python-version: "3.8"
16+
numpy-version: "<2.0"
17+
torch-version: "disable"
18+
torch-pip: "torch==1.13.1+cpu torchvision==0.14.1+cpu --index-url https://download.pytorch.org/whl/cpu"
19+
20+
- python-version: "3.12"
21+
numpy-version: ">=2.0"
1222
steps:
1323
- uses: actions/checkout@v4
1424

@@ -17,8 +27,30 @@ jobs:
1727
with:
1828
python-version: ${{ matrix.python-version }}
1929

20-
- name: Install dependencies
21-
run: uv sync --all-extras
30+
- name: Install specific numpy version
31+
if: matrix.numpy-version != ''
32+
run: uv pip install "numpy${{ matrix.numpy-version }}"
33+
34+
- name: Install w/specific PyTorch version
35+
if: ( matrix.torch-version != '' ) && ( matrix.torch-version != 'disable' )
36+
run: uv sync --extra video --extra dev --extra ${{ matrix.torch-version }}
37+
38+
- name: Install w/CPU PyTorch version
39+
if: matrix.torch-version != 'disable'
40+
run: uv sync --extra video --extra dev --extra cpu
41+
42+
- name: Install w/o PyTorch
43+
if: matrix.torch-version == 'disable'
44+
run: uv sync --extra video --extra dev
45+
46+
- name: Install PyTorch w/Pip
47+
if: matrix.torch-pip != ''
48+
run: uv pip install ${{ matrix.torch-pip }}
49+
50+
# We intentionally run again since some envs force specific numpy versions in this way.
51+
- name: Install specific numpy version
52+
if: matrix.numpy-version != ''
53+
run: uv pip install "numpy${{ matrix.numpy-version }}"
2254

2355
- name: Display Python version
2456
run: uv run python -c "import sys; print(sys.version)"
@@ -27,4 +59,6 @@ jobs:
2759
run: uv pip uninstall opencv-python && uv pip install opencv-python-headless
2860

2961
- name: Test with pytest
30-
run: uv run pytest
62+
run: |
63+
uv pip install pytest
64+
uv run pytest -k 'test_concat' # uv run pytest

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,13 @@ To run all tests, simply run: `pytest`
103103

104104
To break with pdb on error, use: `pytest --pdb -s`
105105

106-
To run a specific test use: `pytest -k 'test_concat' --pdb -s`
106+
To run a specific test use: `pytest -k 'test_concat' --pdb -s`
107+
108+
## Local Installation
109+
110+
To install locally in a self-contained environment with [UV](https://docs.astral.sh/uv/):
111+
112+
```
113+
git clone https://github.com/alexanderswerdlow/image_utils.git
114+
uv sync --extra video --extra dev --extra cpu
115+
```

pyproject.toml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,54 @@ dependencies = [
1414
"numpy>=1.17",
1515
"pillow>=8.0.0",
1616
"einops>=0.3.0",
17-
"jaxtyping>=0.2.19"
17+
"jaxtyping>=0.2.19",
1818
]
1919

2020
[project.urls]
2121
Homepage = "https://github.com/alexanderswerdlow/image_utils"
2222

2323
[project.optional-dependencies]
24-
torch = ["torch", "torchvision"]
2524
video = ["av>=10.0.0", "imageio[ffmpeg]>=2.23.0"]
26-
proc = ["joblib>=1.2.0"]
27-
dev = ["pytest", "pytest-cov", "lovely-tensors>=0.1.14", "lovely-numpy>=0.2.8", "opencv-python"]
25+
dev = ["pytest", "pytest-cov", "lovely-numpy>=0.2.8", "opencv-python", "joblib>=1.2.0"]
26+
cpu = ["torch", "torchvision", "lovely-tensors"]
27+
cu118 = ["torch", "torchvision", "lovely-tensors"]
28+
cu124 = ["torch", "torchvision", "lovely-tensors"]
29+
30+
[tool.uv]
31+
conflicts = [
32+
[
33+
{ extra = "cpu" },
34+
{ extra = "cu118" },
35+
{ extra = "cu124" },
36+
],
37+
]
38+
39+
[tool.uv.sources]
40+
torch = [
41+
{ index = "pytorch-cpu", extra = "cpu" },
42+
{ index = "pytorch-cu118", extra = "cu118" },
43+
{ index = "pytorch-cu124", extra = "cu124" },
44+
]
45+
torchvision = [
46+
{ index = "pytorch-cpu", extra = "cpu" },
47+
{ index = "pytorch-cu118", extra = "cu118" },
48+
{ index = "pytorch-cu124", extra = "cu124" },
49+
]
50+
51+
[[tool.uv.index]]
52+
name = "pytorch-cpu"
53+
url = "https://download.pytorch.org/whl/cpu"
54+
explicit = true
55+
56+
[[tool.uv.index]]
57+
name = "pytorch-cu118"
58+
url = "https://download.pytorch.org/whl/cu118"
59+
explicit = true
60+
61+
[[tool.uv.index]]
62+
name = "pytorch-cu124"
63+
url = "https://download.pytorch.org/whl/cu124"
64+
explicit = true
2865

2966
[build-system]
3067
requires = ["hatchling"]

0 commit comments

Comments
 (0)