From a7cba078dd487fb6c4c6c0bea688a6d589537e0d Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Sun, 27 Jul 2025 01:24:13 -0700 Subject: [PATCH] chore: consolidate essential fixes and add pre-commit hooks - Add pre-commit configuration with ruff and black - Fix lint CI job to use uv tool install instead of sync - Add essential LlamaIndex dependencies to leann-core Co-Authored-By: Yichuan Wang <73766326+yichuan-w@users.noreply.github.com> --- .github/workflows/build-reusable.yml | 8 ++++---- .pre-commit-config.yaml | 23 +++++++++++++++++++++++ packages/leann-core/pyproject.toml | 2 ++ uv.lock | 4 ++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/build-reusable.yml b/.github/workflows/build-reusable.yml index 9109383..1d762c2 100644 --- a/.github/workflows/build-reusable.yml +++ b/.github/workflows/build-reusable.yml @@ -26,17 +26,17 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v4 - - name: Install dependencies + - name: Install ruff run: | - uv sync --dev + uv tool install ruff - name: Run ruff check run: | - uv run ruff check . + ruff check . - name: Run ruff format check run: | - uv run ruff format --check . + ruff format --check . build: needs: lint diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ee7c901 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +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 + - id: check-merge-conflict + - id: debug-statements + + - repo: https://github.com/psf/black + rev: 24.1.1 + hooks: + - id: black + language_version: python3 + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.1 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/packages/leann-core/pyproject.toml b/packages/leann-core/pyproject.toml index 16f94c0..5071c3a 100644 --- a/packages/leann-core/pyproject.toml +++ b/packages/leann-core/pyproject.toml @@ -20,6 +20,8 @@ dependencies = [ "torch>=2.0.0", "sentence-transformers>=2.2.0", "llama-index-core>=0.12.0", + "llama-index-readers-file>=0.4.0", # Essential for document reading + "llama-index-embeddings-huggingface>=0.5.5", # For embeddings "python-dotenv>=1.0.0", "openai>=1.0.0", "huggingface-hub>=0.20.0", diff --git a/uv.lock b/uv.lock index 80e6794..a46abc5 100644 --- a/uv.lock +++ b/uv.lock @@ -1891,6 +1891,8 @@ dependencies = [ { name = "accelerate" }, { name = "huggingface-hub" }, { name = "llama-index-core" }, + { name = "llama-index-embeddings-huggingface" }, + { name = "llama-index-readers-file" }, { name = "mlx", marker = "sys_platform == 'darwin'" }, { name = "mlx-lm", marker = "sys_platform == 'darwin'" }, { name = "msgpack" }, @@ -1916,6 +1918,8 @@ requires-dist = [ { name = "accelerate", marker = "extra == 'colab'", specifier = ">=0.20.0,<1.0.0" }, { name = "huggingface-hub", specifier = ">=0.20.0" }, { name = "llama-index-core", specifier = ">=0.12.0" }, + { name = "llama-index-embeddings-huggingface", specifier = ">=0.5.5" }, + { name = "llama-index-readers-file", specifier = ">=0.4.0" }, { name = "mlx", marker = "sys_platform == 'darwin'", specifier = ">=0.26.3" }, { name = "mlx-lm", marker = "sys_platform == 'darwin'", specifier = ">=0.26.0" }, { name = "msgpack", specifier = ">=1.0.0" },