Skip to content

Commit

Permalink
switch from poetry to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
Adafede committed Nov 25, 2024
1 parent 14b7f0d commit d36ce30
Show file tree
Hide file tree
Showing 7 changed files with 1,250 additions and 2,016 deletions.
47 changes: 18 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,32 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-0
- name: Load cached env
id: cached-env
uses: actions/cache@v4
with:
path: /home/runner/.cache/pypoetry/virtualenvs
key: venv-0
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
virtualenvs-create: true
virtualenvs-in-project: true
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
run: uv python install

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run tests for PR
env:
PYTHONDONTWRITEBYTECODE: 1
run: |
poetry install
poetry run pytest --cov-config=.coveragerc --cov=.
poetry run coverage xml
uv run pytest --cov-config=.coveragerc --cov=.
uv run coverage xml
- name: Get Cover
if: github.event_name == 'pull_request'
uses: orgoro/[email protected]
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.98
- name: Run tests

- name: Run coverage report
if: github.event_name != 'pull_request'
run: |
poetry run coverage report
run: uv run coverage report
33 changes: 14 additions & 19 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-0
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Run update script if cache miss
run: |
poetry install
poetry run python3 update.py
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
run: uv python install

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run update script
run: uv run python update.py
timeout-minutes: 300
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM docker.io/library/python:3.12-slim
RUN apt update && apt install -y libxrender1 libxtst6 libxi6
RUN pip install poetry
COPY poetry.lock pyproject.toml ./
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi
RUN pip install uv
COPY uv.lock pyproject.toml ./
RUN uv sync
RUN mkdir /app
RUN adduser --system --no-create-home nonroot
USER nonroot
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ make tests

To run it yourself, the source is available at: <https://github.com/lotusnprod/lotus-search>:

- Install dependencies using poetry
- If you do not have poetry installed:
- `curl -sSL https://install.python-poetry.org | python3 -`
- Install dependencies using uv
- If you do not have uv installed:
- `curl -LsSf https://astral.sh/uv/install.sh | sh`
- Then:
- `poetry self update && poetry update && poetry install`
- `uv sync`
- Run `python update.py` (takes a few minutes)
- Run `uvicorn main:app --reload` (almost instant)

Expand Down
Loading

0 comments on commit d36ce30

Please sign in to comment.