Skip to content
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

Switch to UV from PDM #40

Merged
merged 13 commits into from
Nov 22, 2024
26 changes: 10 additions & 16 deletions .github/workflows/llm_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,31 @@ jobs:
with:
ref: ${{ github.event.inputs.BRANCH }}

- name: Set up Python
uses: pdm-project/setup-pdm@v3
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.10'
cache: false

- name: Cache pdm cache folder
uses: actions/cache@v4
id: python_cache
with:
path: ./llm-service/.venv
key: pdm-venv-${{ hashFiles('./llm-service/pdm.lock') }}
enable-cache: true
cache-local-path: "./llm-service/uv.lock"

- name: Install Python dependencies
if: steps.python_cache.outputs.cache-hit != 'true'
run: |
pdm install
uv python install 3.10
uv venv
uv pip install -r pyproject.toml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we install from the locked versions instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? Let me see if that's possible

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing a way to install from the lock file instead of the toml.

docs here: https://docs.astral.sh/uv/pip/packages/#installing-packages-from-files

working-directory: llm-service

- name: Run ruff
run: |
pdm run ruff check app
uv run ruff check app
working-directory: llm-service

- name: Run mypy
run: |
pdm run mypy app
uv run mypy app
working-directory: llm-service

- name: Test with pytest
run: |
pdm run pytest -sxvvra
uv run pytest -sxvvra
working-directory: llm-service

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ the Node service locally, you can do so by following these steps:
- Install Python (via [pyenv](https://github.com/pyenv/pyenv), probably) (directly via brew, if you must)
- `cd llm-service`
- Create a virtual environment (`python -m venv venv; source venv/bin/activate`)
- Install dependencies (`python -m pip install -r requirements.txt`)
- Install UV (`python -m pip install uv`)
- Install dependencies (`uv pip install -r pyproject.toml`)
- `fastapi dev`
- ends up running on port 8000

Expand Down
6 changes: 3 additions & 3 deletions llm-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM docker-private.infra.cloudera.com/cloudera_base/hardened/cloudera-python:3.10
RUN pip install pdm
RUN pip install uv
COPY ./pyproject.toml /app/
COPY ./pdm.lock /app/
COPY ./uv.lock /app/
WORKDIR /app
RUN pdm install
RUN uv install
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other places used uv pip install -r pyproject.toml. Why is this different? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that seems right

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be uv sync


COPY ./app /app
WORKDIR /app
Expand Down
2,247 changes: 0 additions & 2,247 deletions llm-service/pdm.lock

This file was deleted.

2 changes: 1 addition & 1 deletion llm-service/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "llm-service"
version = "0.1.0"
description = "Default template for PDM package"
description = "Default template for UV package"
authors = [
{name = "Conrado Silva Miranda", email = "[email protected]"},
]
Expand Down
1,958 changes: 1,958 additions & 0 deletions llm-service/uv.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions local-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ docker run --name qdrant_dev --rm -d -p 6333:6333 -p 6334:6334 -v $(pwd)/databas
cd llm-service
python3.10 -m venv venv
source venv/bin/activate
python -m pip install pdm
pdm install
pdm run pytest -sxvvra
python -m pip install uv
uv pip install -r pyproject.toml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

uv run pytest -sxvvra

pdm run fastapi dev &
uv run fastapi dev &

# start up the jarva
cd ../backend
Expand Down
5 changes: 3 additions & 2 deletions scripts/refresh_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ cd ui/express
npm install

cd ../../llm-service
pip install pdm
pdm install -v
pip install uv
uv venv
uv pip install -r pyproject.toml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same


cd ..
mkdir -p artifacts
Expand Down
2 changes: 1 addition & 1 deletion scripts/startup_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ qdrant/qdrant &

# start Python backend
cd llm-service
pdm run fastapi run --host 127.0.0.1 --port 8081 &
uv run fastapi run --host 127.0.0.1 --port 8081 &

# start up the jarva
cd ..
Expand Down
Loading