Skip to content

Commit 1d7c790

Browse files
committed
feat: switch to uv
1 parent 3b478bf commit 1d7c790

File tree

8 files changed

+1629
-41
lines changed

8 files changed

+1629
-41
lines changed

.github/workflows/publish.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,22 @@ jobs:
3030
name: Tests on ${{ matrix.os }} for ${{ matrix.python-version }}
3131
strategy:
3232
matrix:
33-
python-version: [3.11]
33+
python-version: [3.12]
3434
os: [ubuntu-latest]
3535
runs-on: ${{ matrix.os }}
3636
permissions:
3737
contents: read
3838
steps:
3939
- uses: actions/checkout@v4
40-
- name: Setup Python
41-
uses: actions/setup-python@v5
42-
with:
43-
python-version: ${{ matrix.python-version }}
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v6
42+
43+
- name: Set up Python
44+
run: uv python install
4445
- name: Install dependencies
4546
working-directory: ./src/server/api
4647
run: |
47-
python -m pip install --upgrade pip
48-
pip install -r requirements.txt
49-
pip install -r requirements-dev.txt
48+
uv sync --frozen --no-dev --no-cache-dir
5049
- name: Start containers
5150
working-directory: ./src/server
5251
run: |
@@ -64,7 +63,7 @@ jobs:
6463
working-directory: ./src/server/api
6564
run: |
6665
cp .env.example .env
67-
pytest --junit-xml=junit/test-results-${{ matrix.python-version }}.xml --cov=. --cov-report=xml:coverage-${{ matrix.python-version }}.xml tests/ -s -v
66+
uv run -m pytest --junit-xml=junit/test-results-${{ matrix.python-version }}.xml --cov=. --cov-report=xml:coverage-${{ matrix.python-version }}.xml tests/ -s -v
6867
- name: Upload pytest test results and coverage
6968
uses: actions/upload-artifact@v4
7069
with:

src/server/api/.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.12
1+
3.12

src/server/api/Dockerfile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
FROM python:3.11-slim-buster AS build
1+
FROM python:3.12-slim-bookworm
2+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
23

34

5+
# Set working directory
46
WORKDIR /app
57

6-
COPY ./requirements.txt /app/requirements.txt
7-
RUN python3.11 -m pip install -r requirements.txt --no-cache-dir
8+
# Copy dependency files
9+
COPY ./pyproject.toml /app
10+
COPY ./uv.lock /app
811

12+
# Install Python dependencies using uv
13+
RUN uv sync --frozen --no-dev --no-cache-dir
14+
15+
# Copy the application code
916
COPY ./memobase_server /app/memobase_server
1017
COPY ./api.py /app
1118

1219

13-
CMD ["python3.11", "-m", "fastapi", "run", "api.py"]
20+
21+
# Expose port 8000 (FastAPI default)
22+
EXPOSE 8000
23+
24+
# Set environment variables
25+
ENV PYTHONUNBUFFERED=1
26+
27+
# Run the FastAPI server using uvicorn
28+
CMD ["/app/.venv/bin/uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]

src/server/api/pyproject.toml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
[project]
2-
name = "api"
2+
name = "memobase_server"
33
version = "0.1.0"
4-
description = "Add your description here"
4+
description = "Memobase Server"
55
readme = "README.md"
6-
requires-python = ">=3.13"
7-
dependencies = []
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"fastapi[standard]>=0.116.1",
9+
"numpy>=2.3.1",
10+
"openai>=1.97.0",
11+
"opentelemetry-api>=1.35.0",
12+
"opentelemetry-exporter-prometheus>=0.56b0",
13+
"opentelemetry-instrumentation-fastapi>=0.56b0",
14+
"opentelemetry-sdk>=1.35.0",
15+
"pgvector>=0.4.1",
16+
"psycopg2-binary>=2.9.10",
17+
"python-dotenv>=1.1.1",
18+
"pyyaml>=6.0.2",
19+
"redis>=6.2.0",
20+
"sqlalchemy>=2.0.41",
21+
"tiktoken>=0.9.0",
22+
"typeguard>=4.4.4",
23+
"volcengine-python-sdk[ark]>=4.0.6",
24+
]
25+
26+
[dependency-groups]
27+
dev = [
28+
"alembic>=1.16.4",
29+
"pytest>=8.4.1",
30+
"pytest-asyncio>=1.1.0",
31+
"pytest-cov>=6.2.1",
32+
]

src/server/api/requirements-dev.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/server/api/requirements.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/server/api/uv.lock

Lines changed: 1569 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ Check out the [docs](https://docs.memobase.io/quickstart) of how to use Memobase
8888

8989
1. Start a local DB first by `sh script/up-dev.sh`
9090
2. Open a new terminal window and `cd ./api`
91-
3. Install python deps: `pip install -r requirements.txt`
92-
4. To test if you got everything right, run `pytest` to see if all the tests are passed.
93-
5. Launch Memobase Server in dev mode: `fastapi dev --port 8019`
91+
3. Install python deps: `uv sync`
92+
4. To test if you got everything right, run `uv run pytest` to see if all the tests are passed.
93+
5. Launch Memobase Server in dev mode: `uv run -m fastapi dev --port 8019`
9494

9595
> `fastapi dev` has hot-reload, so you can just modify the code and test it without relaunch the service.
9696

0 commit comments

Comments
 (0)