Skip to content

Commit 7c7d4f2

Browse files
Migrate from poetry to uv (#355)
Beyond poetry dependency resolution being the bane of my existence... `uv` is just better. **Faster, stronger..** This PR introduces `uv` as our new package manager and greatly improves the economics of our testing CI workflow on a few fronts: - Updated versions of common actions - DRY(er) environment var setup - Isolated dependency installs during CI tests - Caching enabled for all of the things
1 parent 6b0d39a commit 7c7d4f2

22 files changed

+6106
-7154
lines changed

.github/workflows/lint.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Lint
32

43
on:
@@ -8,7 +7,7 @@ on:
87
- main
98

109
env:
11-
POETRY_VERSION: "2.0.1"
10+
UV_VERSION: "0.7.13"
1211

1312
jobs:
1413
check:
@@ -31,24 +30,36 @@ jobs:
3130
- "3.13"
3231

3332
steps:
34-
- uses: actions/checkout@v2
35-
- name: Set up Python ${{ matrix.python-version }}
36-
uses: actions/setup-python@v2
33+
- name: Check out repository
34+
uses: actions/checkout@v4
35+
36+
- name: Install Python
37+
uses: actions/setup-python@v5
3738
with:
3839
python-version: ${{ matrix.python-version }}
39-
- name: Install Poetry
40-
uses: snok/install-poetry@v1
40+
41+
- name: Install uv
42+
uses: astral-sh/setup-uv@v6
4143
with:
42-
version: ${{ env.POETRY_VERSION }}
44+
version: ${{ env.UV_VERSION }}
45+
enable-cache: true
46+
python-version: ${{ matrix.python-version }} # sets UV_PYTHON
47+
cache-dependency-glob: |
48+
pyproject.toml
49+
uv.lock
50+
4351
- name: Install dependencies
4452
run: |
45-
poetry install --all-extras
53+
uv sync --all-extras --frozen
54+
4655
- name: check-sort-import
4756
run: |
48-
poetry run check-sort-imports
57+
make check-sort-imports
58+
4959
- name: check-black-format
5060
run: |
51-
poetry run check-format
61+
make check-format
62+
5263
- name: check-mypy
5364
run: |
54-
poetry run check-mypy
65+
make check-types

.github/workflows/release.yml

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,37 @@ on:
66

77
env:
88
PYTHON_VERSION: "3.11"
9-
POETRY_VERSION: "2.0.1"
9+
UV_VERSION: "0.7.13"
1010

1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- name: Check out repository
17+
uses: actions/checkout@v4
1718

18-
- name: Set up Python
19-
uses: actions/setup-python@v4
19+
- name: Install Python
20+
uses: actions/setup-python@v5
2021
with:
2122
python-version: ${{ env.PYTHON_VERSION }}
2223

23-
- name: Install Poetry
24-
uses: snok/install-poetry@v1
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v6
2526
with:
26-
version: ${{ env.POETRY_VERSION }}
27+
version: ${{ env.UV_VERSION }}
28+
enable-cache: true
29+
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
30+
cache-dependency-glob: |
31+
pyproject.toml
32+
uv.lock
33+
34+
- name: Install dependencies
35+
run: |
36+
uv sync --frozen
2737
2838
- name: Build package
29-
run: poetry build
39+
run: uv build
3040

3141
- name: Upload build
3242
uses: actions/upload-artifact@v4
@@ -39,24 +49,35 @@ jobs:
3949
runs-on: ubuntu-latest
4050

4151
steps:
42-
- uses: actions/checkout@v4
52+
- name: Check out repository
53+
uses: actions/checkout@v4
4354

44-
- name: Set up Python
45-
uses: actions/setup-python@v4
55+
- name: Install Python
56+
uses: actions/setup-python@v5
4657
with:
4758
python-version: ${{ env.PYTHON_VERSION }}
4859

49-
- name: Install Poetry
50-
uses: snok/install-poetry@v1
60+
- name: Install uv
61+
uses: astral-sh/setup-uv@v6
5162
with:
52-
version: ${{ env.POETRY_VERSION }}
63+
version: ${{ env.UV_VERSION }}
64+
enable-cache: true
65+
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
66+
cache-dependency-glob: |
67+
pyproject.toml
68+
uv.lock
69+
70+
- name: Install dependencies
71+
run: |
72+
uv sync --frozen
5373
54-
- uses: actions/download-artifact@v4
74+
- name: Download build artifacts
75+
uses: actions/download-artifact@v4
5576
with:
5677
name: dist
5778
path: dist/
5879

5980
- name: Publish to PyPI
6081
env:
61-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI }}
62-
run: poetry publish
82+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI }}
83+
run: uv publish

.github/workflows/test.yml

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
env:
1616
PYTHON_VERSION: "3.11"
17-
POETRY_VERSION: "2.0.1"
17+
UV_VERSION: "0.7.13"
1818

1919
jobs:
2020
service-tests:
@@ -24,11 +24,10 @@ jobs:
2424
HF_HOME: ${{ github.workspace }}/hf_cache
2525
steps:
2626
- name: Check out repository
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828

2929
- name: Cache HuggingFace Models
30-
id: hf-cache
31-
uses: actions/cache@v3
30+
uses: actions/cache@v4
3231
with:
3332
path: hf_cache
3433
key: ${{ runner.os }}-hf-cache
@@ -38,20 +37,24 @@ jobs:
3837
mkdir -p ~/.huggingface
3938
echo '{"token":"${{ secrets.HF_TOKEN }}"}' > ~/.huggingface/token
4039
41-
- name: Set up Python 3.11
42-
uses: actions/setup-python@v4
40+
- name: Install Python
41+
uses: actions/setup-python@v5
4342
with:
4443
python-version: ${{ env.PYTHON_VERSION }}
45-
cache: pip
4644

47-
- name: Install Poetry
48-
uses: snok/install-poetry@v1
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v6
4947
with:
50-
version: ${{ env.POETRY_VERSION }}
48+
version: ${{ env.UV_VERSION }}
49+
enable-cache: true
50+
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
51+
cache-dependency-glob: |
52+
pyproject.toml
53+
uv.lock
5154
5255
- name: Install dependencies
5356
run: |
54-
poetry install --all-extras
57+
uv sync --all-extras
5558
5659
- name: Authenticate to Google Cloud
5760
uses: google-github-actions/auth@v1
@@ -61,7 +64,6 @@ jobs:
6164
- name: Run full test suite and prime the HF cache
6265
env:
6366
HF_TOKEN: ${{ secrets.HF_TOKEN }}
64-
HF_HOME: ${{ github.workspace }}/hf_cache
6567
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
6668
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
6769
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
@@ -87,45 +89,48 @@ jobs:
8789
fail-fast: false
8890
matrix:
8991
# 3.11 tests are run in the service-tests job
90-
python-version: ["3.9", "3.10", 3.12, 3.13]
92+
python-version: ["3.9", "3.10", "3.12", "3.13"]
9193
redis-py-version: ["5.x", "6.x"]
92-
redis-version: ["6.2.6-v9", "latest", "8.0.1"]
93-
94+
redis-version: ["6.2.6-v9", "latest", "8.0.2"]
9495
steps:
9596
- name: Check out repository
96-
uses: actions/checkout@v3
97+
uses: actions/checkout@v4
9798

9899
- name: Cache HuggingFace Models
99-
uses: actions/cache@v3
100+
uses: actions/cache@v4
100101
with:
101102
path: hf_cache
102103
key: ${{ runner.os }}-hf-cache
103104

104-
- name: Set up Python ${{ matrix.python-version }}
105-
uses: actions/setup-python@v4
105+
- name: Install Python
106+
uses: actions/setup-python@v5
106107
with:
107108
python-version: ${{ matrix.python-version }}
108-
cache: pip
109109

110-
- name: Install Poetry
111-
uses: snok/install-poetry@v1
110+
- name: Install uv
111+
uses: astral-sh/setup-uv@v6
112112
with:
113-
version: ${{ env.POETRY_VERSION }}
113+
version: ${{ env.UV_VERSION }}
114+
enable-cache: true
115+
python-version: ${{ matrix.python-version }} # sets UV_PYTHON
116+
cache-dependency-glob: |
117+
pyproject.toml
118+
uv.lock
114119
115120
- name: Install dependencies
116121
run: |
117-
poetry install --all-extras
122+
uv sync --all-extras
118123
119124
# Install right redis version based on redis py
120125
if [[ "${{ matrix.redis-py-version }}" == "5.x" ]]; then
121-
poetry run pip install "redis>=5.0.0,<6.0.0"
126+
uv pip install "redis>=5,<6"
122127
else
123-
poetry run pip install "redis>=6.0.0,<7.0.0"
128+
uv pip install "redis>=6,<7"
124129
fi
125130
126131
- name: Set Redis image name
127132
run: |
128-
if [[ "${{ matrix.redis-version }}" == "8.0.1" ]]; then
133+
if [[ "${{ matrix.redis-version }}" == "8.0.2" ]]; then
129134
echo "REDIS_IMAGE=redis:${{ matrix.redis-version }}" >> $GITHUB_ENV
130135
else
131136
echo "REDIS_IMAGE=redis/redis-stack-server:${{ matrix.redis-version }}" >> $GITHUB_ENV
@@ -138,7 +143,6 @@ jobs:
138143

139144
- name: Run tests
140145
env:
141-
HF_HOME: ${{ github.workspace }}/hf_cache
142146
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
143147
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
144148
run: |
@@ -147,7 +151,6 @@ jobs:
147151
- name: Run notebooks
148152
if: matrix.redis-py-version == '6.x' && matrix.redis-version == 'latest'
149153
env:
150-
HF_HOME: ${{ github.workspace }}/hf_cache
151154
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
152155
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
153156
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
@@ -171,20 +174,24 @@ jobs:
171174
- name: Check out repository
172175
uses: actions/checkout@v3
173176

174-
- name: Set up Python
175-
uses: actions/setup-python@v4
177+
- name: Install Python
178+
uses: actions/setup-python@v5
176179
with:
177180
python-version: ${{ env.PYTHON_VERSION }}
178-
cache: pip
179181

180-
- name: Install Poetry
181-
uses: snok/install-poetry@v1
182+
- name: Install uv
183+
uses: astral-sh/setup-uv@v6
182184
with:
183-
version: ${{ env.POETRY_VERSION }}
184-
185+
version: ${{ env.UV_VERSION }}
186+
enable-cache: true
187+
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
188+
cache-dependency-glob: |
189+
pyproject.toml
190+
uv.lock
191+
185192
- name: Install dependencies
186193
run: |
187-
poetry install --all-extras
194+
uv sync --group docs --frozen
188195
189196
- name: Build docs
190197
run: |

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
repos:
22
- repo: local
33
hooks:
4-
- id: poetry-checks
4+
- id: code-quality-checks
55
name: Run pre-commit checks (format, sort-imports, check-mypy)
6-
entry: bash -c 'poetry run format && poetry run sort-imports && poetry run check-mypy'
6+
entry: bash -c 'make format && make check-sort-imports && make check-types'
77
language: system
8-
pass_filenames: false
8+
pass_filenames: false

0 commit comments

Comments
 (0)