Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ vite.config.js
*.tfstate.*
.terraform/
.aws/
.gcloud/
.gcloud/
13 changes: 6 additions & 7 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: install git lfs
run: |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: setup python
uses: actions/setup-python@v2
with:
python-version: "3.10"
run: uv python install 3.10

- name: install python packages
run: |
python -m pip install --upgrade pip
pip install .
run: uv pip install --system .

- name: track large files
run: git lfs track "database/pipeline.pkl"
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lint and Test

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: Set up Python
run: uv python install 3.11

- name: Run Ruff linter
run: uvx ruff check .

- name: Run Ruff formatter check
run: uvx ruff format --check .

- name: Run mypy
run: uvx mypy . --ignore-missing-imports

pre-commit:
name: Pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: Set up Python
run: uv python install 3.11

- name: Run pre-commit
run: uvx pre-commit run --all-files
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ dmypy.json
# Pyre type checker
.pyre/

*DS_Store
*DS_Store
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: []
args: [--ignore-missing-imports]
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
FROM python:3.10-slim

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Clone the repository
WORKDIR /code

# Copy the necessary files (you may skip this if already in the repository)
# Copy the necessary files
COPY database/pipeline.pkl /code/database/pipeline.pkl
COPY requirements.txt /code/requirements.txt
COPY setup.py /code/setup.py
COPY pyproject.toml /code/pyproject.toml
COPY knowledge_database /code/knowledge_database
COPY api /code/api

# Install Python dependencies
RUN pip install pip --upgrade
RUN pip install --no-cache-dir -r requirements.txt
# Install Python dependencies using uv
RUN uv pip install --system .

# Set up the secret environment variable for OpenAI API Key
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'
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.
73 changes: 70 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,74 @@
launch:
.PHONY: install install-dev sync dev api run lint lint-fix check pre-commit pre-commit-install docker-build docker-run launch clean

# Install dependencies
install:
uv sync --no-dev

# Install with dev dependencies
install-dev:
uv sync --all-extras

# Sync dependencies (alias for install-dev)
sync:
uv sync --all-extras

# Start local dev server
dev:
uv run uvicorn api.api:app --reload --port 8000

# Start API server (production-like)
api:
uv run uvicorn api.api:app --host 0.0.0.0 --port 8080

# Run the data extraction pipeline
run:
uv run python run.py

# Linting and formatting check
lint:
uv run ruff check .
uv run ruff format --check .
uv run mypy . --ignore-missing-imports

# Auto-fix linting issues
lint-fix:
uv run ruff check --fix .
uv run ruff format .

# Run all checks (lint + type check)
check: lint

# Run pre-commit hooks on all files
pre-commit:
uv run pre-commit run --all-files

# Install pre-commit hooks
pre-commit-install:
uv run pre-commit install

# Build Docker image
docker-build:
echo ${OPENAI_API_KEY} > mysecret.txt
docker build --secret id=OPENAI_API_KEY,src=mysecret.txt -t knowledge .
rm -f mysecret.txt

# Run Docker container
docker-run:
docker run -d --add-host host.docker.internal:host-gateway --name run_knowledge -p 8080:8080 knowledge

local-dev-api:
uvicorn api.api:app --reload
# Build and run Docker (legacy command)
launch: docker-build docker-run

# Stop and remove Docker container
docker-stop:
docker stop run_knowledge || true
docker rm run_knowledge || true

# Clean up
clean:
rm -rf .venv
rm -rf __pycache__
rm -rf .mypy_cache
rm -rf .ruff_cache
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
Loading