Skip to content

Commit e795072

Browse files
authored
Move to uv (#1246)
1 parent fadc146 commit e795072

13 files changed

Lines changed: 1983 additions & 3326 deletions

File tree

.github/workflows/feedtest.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,19 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v4
3737
- run:
38-
sudo apt-get update && sudo apt-get install -y python3-pip && sudo pip3 install poetry
38+
sudo apt-get update && sudo apt-get install -y python3-pip && sudo pip3 install uv
3939
- name: Set up Python ${{ matrix.python-version }}
4040
uses: actions/setup-python@v4
4141
with:
4242
python-version: ${{ matrix.python-version }}
43-
cache: poetry
4443
- name: Install Python dependencies
45-
run: poetry install --no-root --with plugins
44+
run: uv sync --all-extras
4645
- name: Copy dummy config file
4746
run: cp yeti.conf.sample yeti.conf
4847
- name: Start redis & arangodb conainers
4948
run: docker compose -f extras/docker/dev/docker-compose.yaml up -d redis arangodb
5049
- name: Start event consumer
51-
run: poetry run python -m core.events.consumers events & sleep 5
50+
run: uv run python -m core.events.consumers events & sleep 5
5251
- name: Run test feeds
5352
run: |
54-
poetry run python -m unittest discover -s tests/ -p 'feeds.py'
53+
uv run python -m unittest discover -s tests/ -p 'feeds.py'

.github/workflows/ruff.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11+
- run:
12+
sudo apt-get update && sudo apt-get install -y python3-pip && sudo pip3 install uv
1113
- uses: actions/setup-python@v4
1214
- name: Install ruff
13-
run: pip install ruff
15+
run: uv tool install ruff
1416
- name: Run ruff lint check
1517
run: ruff check .
1618
- name: Run ruff format check

.github/workflows/unittests.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,19 @@ jobs:
2929
steps:
3030
- uses: actions/checkout@v4
3131
- run:
32-
sudo apt-get update && sudo apt-get install -y python3-pip && sudo pip3 install poetry
32+
sudo apt-get update && sudo apt-get install -y python3-pip && sudo pip3 install uv
3333
- name: Set up Python ${{ matrix.python-version }}
3434
uses: actions/setup-python@v4
3535
with:
3636
python-version: ${{ matrix.python-version }}
37-
cache: poetry
3837
- name: Install Python dependencies
39-
run: poetry install --no-root
38+
run: uv sync --group dev
4039
- name: Copy dummy config file
4140
run: cp yeti.conf.sample yeti.conf
4241
- name: Start redis & arangodb conainers
4342
run: docker compose -f extras/docker/dev/docker-compose.yaml up -d redis arangodb
4443
- name: Test with unittest
4544
run: |
46-
poetry run python -m unittest discover -s tests/schemas -p '*.py'
47-
poetry run python -m unittest discover -s tests/apiv2 -p '*.py'
48-
poetry run python -m unittest discover -s tests/core_tests -p '*.py'
45+
uv run python -m unittest discover -s tests/schemas -p '*.py'
46+
uv run python -m unittest discover -s tests/apiv2 -p '*.py'
47+
uv run python -m unittest discover -s tests/core_tests -p '*.py'

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

core/clients/file_storage/classes/s3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
except ImportError:
99
boto3 = None
1010
logging.warning(
11-
"boto3 is not imported, if you wish to use s3 file storage please install with `poetry install --extras s3`"
11+
"boto3 is not imported, if you wish to use s3 file storage please install with `uv sync --group s3`"
1212
)
1313

1414

@@ -18,7 +18,7 @@ class S3Client(FileStorageClient):
1818
def __init__(self, path: str):
1919
if boto3 is None:
2020
logging.warning(
21-
"Attempting to use `S3Client` without `boto3` installed; install with `poetry install --extras s3`"
21+
"Attempting to use `S3Client` without `boto3` installed; install with `uv sync --group s3`"
2222
)
2323
raise ImportError("boto3 is not installed")
2424

core/schemas/template.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33
from typing import TYPE_CHECKING, Literal, Optional
44

5-
import jinja2
5+
import minijinja
66
from pydantic import BaseModel, ConfigDict, computed_field
77

88
from core.config.config import yeti_config
@@ -22,9 +22,8 @@ class Template(BaseModel):
2222
def render(self, data: list["Observable"], output_file: str | None) -> None | str:
2323
"""Renders the template with the given data to the output file."""
2424

25-
environment = jinja2.Environment()
26-
template = environment.from_string(self.template)
27-
result = template.render(data=data)
25+
environment = minijinja.Environment(templates={self.name: self.template})
26+
result = environment.render_template(self.name, data=data)
2827
if output_file:
2928
os.makedirs(os.path.dirname(output_file), exist_ok=True)
3029
with open(output_file, "w+") as fd:

extras/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ RUN cp yeti.conf.sample yeti.conf
1414
RUN cp ./extras/docker/docker-entrypoint.sh /docker-entrypoint.sh
1515

1616
# Upgrade pip
17-
RUN pip3 install --upgrade pip && pip3 install poetry
17+
RUN pip3 install --upgrade pip && pip3 install uv
1818

1919
# Install yeti
20-
RUN poetry install --no-root --with plugins
20+
RUN uv sync --group plugins
2121

2222
ENV PYTHONPATH /app
2323

extras/docker/dev/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ RUN apt-get update && apt-get install -y \
1010
git
1111

1212
# Upgrade pip
13-
RUN pip3 install --upgrade pip && pip3 install poetry
13+
RUN pip3 install --upgrade pip && pip3 install uv
1414

1515
# Install & Configure YETI
1616
ADD . /app
1717
WORKDIR /app
18-
RUN poetry install --no-root --with dev,plugins
18+
RUN uv sync --all-groups
1919

2020
COPY --chmod=744 ./extras/docker/docker-entrypoint.sh /docker-entrypoint.sh
2121

extras/docker/docker-entrypoint.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22
set -euo pipefail
33

44
if [[ "$1" = 'webserver' ]]; then
5-
poetry run uvicorn core.web.webapp:app --reload --host 0.0.0.0 --log-level=debug
5+
uv run uvicorn core.web.webapp:app --reload --host 0.0.0.0 --log-level=debug
66
elif [[ "$1" = 'webserver-prod' ]]; then
7-
poetry run uvicorn core.web.webapp:app --host 0.0.0.0 --workers $(nproc --all || echo 4) --log-level=info
7+
uv run uvicorn core.web.webapp:app --host 0.0.0.0 --workers $(nproc --all || echo 4) --log-level=info
88
elif [[ "$1" = 'tasks' ]]; then
9-
poetry run celery -A core.taskscheduler worker --loglevel=INFO --purge -P threads
9+
uv run celery -A core.taskscheduler worker --loglevel=INFO --purge -P threads
1010
elif [[ "$1" = 'tasks-beat' ]]; then
11-
rm -f celerybeat-schedule.db && poetry run celery -A core.taskscheduler beat
11+
rm -f celerybeat-schedule.db && uv run celery -A core.taskscheduler beat
1212
elif [[ "$1" = 'events-tasks' ]]; then
13-
poetry run python -m core.events.consumers events
13+
uv run python -m core.events.consumers events
1414
elif [[ "$1" = 'create-user' ]]; then
15-
poetry run python yetictl/cli.py create-user "${@:2}"
15+
uv run python yetictl/cli.py create-user "${@:2}"
1616
elif [[ "$1" = 'reset-password' ]]; then
17-
poetry run python yetictl/cli.py reset-password "${@:2}"
17+
uv run python yetictl/cli.py reset-password "${@:2}"
1818
elif [[ "$1" = 'toggle-user' ]]; then
19-
poetry run python yetictl/cli.py toggle-user "${@:2}"
19+
uv run python yetictl/cli.py toggle-user "${@:2}"
2020
elif [[ "$1" = 'toggle-admin' ]]; then
21-
poetry run python yetictl/cli.py toggle-admin "${@:2}"
21+
uv run python yetictl/cli.py toggle-admin "${@:2}"
2222
elif [[ "$1" = 'migrate-arangodb' ]]; then
23-
poetry run python yetictl/cli.py migrate-arangodb "${@:2}"
23+
uv run python yetictl/cli.py migrate-arangodb "${@:2}"
2424
elif [[ "$1" = 'envshell' ]]; then
25-
$(poetry env activate) && exec bash
25+
$(uv venv activate) && exec bash
2626
else
2727
exec "$@"
2828
fi

extras/git/ruff-precommit-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# This script gives a poor error message due to https://github.com/microsoft/vscode/issues/189924
33
# but still blocks the commit from happening, so sorta WAI
4-
poetry run ruff check . && poetry run ruff format . --check
4+
uv run ruff check . && uv run ruff format . --check
55

66
# Check the exit status of the previous command
77

0 commit comments

Comments
 (0)