Skip to content

Migrate from poetry to uv #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Lint

on:
Expand All @@ -8,7 +7,7 @@ on:
- main

env:
POETRY_VERSION: "2.0.1"
UV_VERSION: "0.7.13"

jobs:
check:
Expand All @@ -31,24 +30,36 @@ jobs:
- "3.13"

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Check out repository
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: ${{ env.POETRY_VERSION }}
version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ matrix.python-version }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Install dependencies
run: |
poetry install --all-extras
uv sync --all-extras --frozen

- name: check-sort-import
run: |
poetry run check-sort-imports
make check-sort-imports

- name: check-black-format
run: |
poetry run check-format
make check-format

- name: check-mypy
run: |
poetry run check-mypy
make check-types
55 changes: 38 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,37 @@ on:

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "2.0.1"
UV_VERSION: "0.7.13"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: ${{ env.POETRY_VERSION }}
version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Install dependencies
run: |
uv sync --frozen

- name: Build package
run: poetry build
run: uv build

- name: Upload build
uses: actions/upload-artifact@v4
Expand All @@ -39,24 +49,35 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: ${{ env.POETRY_VERSION }}
version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Install dependencies
run: |
uv sync --frozen

- uses: actions/download-artifact@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI }}
run: poetry publish
UV_PUBLISH_TOKEN: ${{ secrets.PYPI }}
run: uv publish
81 changes: 44 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "2.0.1"
UV_VERSION: "0.7.13"

jobs:
service-tests:
Expand All @@ -24,11 +24,10 @@ jobs:
HF_HOME: ${{ github.workspace }}/hf_cache
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache HuggingFace Models
id: hf-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: hf_cache
key: ${{ runner.os }}-hf-cache
Expand All @@ -38,20 +37,24 @@ jobs:
mkdir -p ~/.huggingface
echo '{"token":"${{ secrets.HF_TOKEN }}"}' > ~/.huggingface/token

- name: Set up Python 3.11
uses: actions/setup-python@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: ${{ env.POETRY_VERSION }}
version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Install dependencies
run: |
poetry install --all-extras
uv sync --all-extras

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
Expand All @@ -61,7 +64,6 @@ jobs:
- name: Run full test suite and prime the HF cache
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_HOME: ${{ github.workspace }}/hf_cache
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
Expand All @@ -87,45 +89,48 @@ jobs:
fail-fast: false
matrix:
# 3.11 tests are run in the service-tests job
python-version: ["3.9", "3.10", 3.12, 3.13]
python-version: ["3.9", "3.10", "3.12", "3.13"]
redis-py-version: ["5.x", "6.x"]
redis-version: ["6.2.6-v9", "latest", "8.0.1"]

redis-version: ["6.2.6-v9", "latest", "8.0.2"]
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache HuggingFace Models
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: hf_cache
key: ${{ runner.os }}-hf-cache

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: ${{ env.POETRY_VERSION }}
version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ matrix.python-version }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Install dependencies
run: |
poetry install --all-extras
uv sync --all-extras

# Install right redis version based on redis py
if [[ "${{ matrix.redis-py-version }}" == "5.x" ]]; then
poetry run pip install "redis>=5.0.0,<6.0.0"
uv pip install "redis>=5,<6"
else
poetry run pip install "redis>=6.0.0,<7.0.0"
uv pip install "redis>=6,<7"
fi

- name: Set Redis image name
run: |
if [[ "${{ matrix.redis-version }}" == "8.0.1" ]]; then
if [[ "${{ matrix.redis-version }}" == "8.0.2" ]]; then
echo "REDIS_IMAGE=redis:${{ matrix.redis-version }}" >> $GITHUB_ENV
else
echo "REDIS_IMAGE=redis/redis-stack-server:${{ matrix.redis-version }}" >> $GITHUB_ENV
Expand All @@ -138,7 +143,6 @@ jobs:

- name: Run tests
env:
HF_HOME: ${{ github.workspace }}/hf_cache
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
run: |
Expand All @@ -147,7 +151,6 @@ jobs:
- name: Run notebooks
if: matrix.redis-py-version == '6.x' && matrix.redis-version == 'latest'
env:
HF_HOME: ${{ github.workspace }}/hf_cache
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
Expand All @@ -171,20 +174,24 @@ jobs:
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: ${{ env.POETRY_VERSION }}

version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Install dependencies
run: |
poetry install --all-extras
uv sync --group docs --frozen

- name: Build docs
run: |
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
repos:
- repo: local
hooks:
- id: poetry-checks
- id: code-quality-checks
name: Run pre-commit checks (format, sort-imports, check-mypy)
entry: bash -c 'poetry run format && poetry run sort-imports && poetry run check-mypy'
entry: bash -c 'make format && make check-sort-imports && make check-types'
language: system
pass_filenames: false
pass_filenames: false
Loading
Loading