Skip to content

Commit 05b295b

Browse files
committed
Update project
1 parent b440de9 commit 05b295b

34 files changed

Lines changed: 3640 additions & 628 deletions

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ vite.config.js
119119
*.tfstate.*
120120
.terraform/
121121
.aws/
122-
.gcloud/
122+
.gcloud/

.github/workflows/database.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: checkout repo content
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616

1717
- name: install git lfs
1818
run: |
1919
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
2020
sudo apt-get install git-lfs
2121
git lfs install
2222
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v4
25+
2326
- name: setup python
24-
uses: actions/setup-python@v2
25-
with:
26-
python-version: "3.10"
27+
run: uv python install 3.10
2728

2829
- name: install python packages
29-
run: |
30-
python -m pip install --upgrade pip
31-
pip install .
30+
run: uv pip install --system .
3231

3332
- name: track large files
3433
run: git lfs track "database/pipeline.pkl"

.github/workflows/lint.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Lint and Test
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v4
18+
19+
- name: Set up Python
20+
run: uv python install 3.11
21+
22+
- name: Run Ruff linter
23+
run: uvx ruff check .
24+
25+
- name: Run Ruff formatter check
26+
run: uvx ruff format --check .
27+
28+
- name: Run mypy
29+
run: uvx mypy . --ignore-missing-imports
30+
31+
pre-commit:
32+
name: Pre-commit hooks
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v4
39+
40+
- name: Set up Python
41+
run: uv python install 3.11
42+
43+
- name: Run pre-commit
44+
run: uvx pre-commit run --all-files

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ dmypy.json
132132
# Pyre type checker
133133
.pyre/
134134

135-
*DS_Store
135+
*DS_Store

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.8.0
12+
hooks:
13+
- id: ruff
14+
args: [--fix]
15+
- id: ruff-format
16+
17+
- repo: https://github.com/pre-commit/mirrors-mypy
18+
rev: v1.13.0
19+
hooks:
20+
- id: mypy
21+
additional_dependencies: []
22+
args: [--ignore-missing-imports]

Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
FROM python:3.10-slim
22

3+
# Install uv
4+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
5+
36
# Clone the repository
47
WORKDIR /code
58

6-
# Copy the necessary files (you may skip this if already in the repository)
9+
# Copy the necessary files
710
COPY database/pipeline.pkl /code/database/pipeline.pkl
8-
COPY requirements.txt /code/requirements.txt
9-
COPY setup.py /code/setup.py
11+
COPY pyproject.toml /code/pyproject.toml
1012
COPY knowledge_database /code/knowledge_database
1113
COPY api /code/api
1214

13-
# Install Python dependencies
14-
RUN pip install pip --upgrade
15-
RUN pip install --no-cache-dir -r requirements.txt
15+
# Install Python dependencies using uv
16+
RUN uv pip install --system .
1617

1718
# Set up the secret environment variable for OpenAI API Key
1819
RUN --mount=type=secret,id=OPENAI_API_KEY sh -c 'echo "export OPENAI_API_KEY=$(cat /run/secrets/OPENAI_API_KEY)" >> /etc/profile.d/openai.sh'

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
671671
may consider it more useful to permit linking proprietary applications with
672672
the library. If this is what you want to do, use the GNU Lesser General
673673
Public License instead of this License. But first, please read
674-
<https://www.gnu.org/licenses/why-not-lgpl.html>.
674+
<https://www.gnu.org/licenses/why-not-lgpl.html>.

Makefile

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,74 @@
1-
launch:
1+
.PHONY: install install-dev sync dev api run lint lint-fix check pre-commit pre-commit-install docker-build docker-run launch clean
2+
3+
# Install dependencies
4+
install:
5+
uv sync --no-dev
6+
7+
# Install with dev dependencies
8+
install-dev:
9+
uv sync --all-extras
10+
11+
# Sync dependencies (alias for install-dev)
12+
sync:
13+
uv sync --all-extras
14+
15+
# Start local dev server
16+
dev:
17+
uv run uvicorn api.api:app --reload --port 8000
18+
19+
# Start API server (production-like)
20+
api:
21+
uv run uvicorn api.api:app --host 0.0.0.0 --port 8080
22+
23+
# Run the data extraction pipeline
24+
run:
25+
uv run python run.py
26+
27+
# Linting and formatting check
28+
lint:
29+
uv run ruff check .
30+
uv run ruff format --check .
31+
uv run mypy . --ignore-missing-imports
32+
33+
# Auto-fix linting issues
34+
lint-fix:
35+
uv run ruff check --fix .
36+
uv run ruff format .
37+
38+
# Run all checks (lint + type check)
39+
check: lint
40+
41+
# Run pre-commit hooks on all files
42+
pre-commit:
43+
uv run pre-commit run --all-files
44+
45+
# Install pre-commit hooks
46+
pre-commit-install:
47+
uv run pre-commit install
48+
49+
# Build Docker image
50+
docker-build:
251
echo ${OPENAI_API_KEY} > mysecret.txt
352
docker build --secret id=OPENAI_API_KEY,src=mysecret.txt -t knowledge .
53+
rm -f mysecret.txt
54+
55+
# Run Docker container
56+
docker-run:
457
docker run -d --add-host host.docker.internal:host-gateway --name run_knowledge -p 8080:8080 knowledge
558

6-
local-dev-api:
7-
uvicorn api.api:app --reload
59+
# Build and run Docker (legacy command)
60+
launch: docker-build docker-run
861

9-
# Start local dev server using uv
10-
dev:
11-
uv run uvicorn api.api:app --reload --port 8000
62+
# Stop and remove Docker container
63+
docker-stop:
64+
docker stop run_knowledge || true
65+
docker rm run_knowledge || true
1266

13-
# Install dependencies with uv
14-
install:
15-
uv pip install -r requirements.txt
67+
# Clean up
68+
clean:
69+
rm -rf .venv
70+
rm -rf __pycache__
71+
rm -rf .mypy_cache
72+
rm -rf .ruff_cache
73+
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
74+
find . -type f -name "*.pyc" -delete 2>/dev/null || true

0 commit comments

Comments
 (0)