From 463bb48222baab5be3ef79e4d3e5d3b5cb03fbfe Mon Sep 17 00:00:00 2001 From: phact Date: Fri, 12 Sep 2025 13:02:56 -0400 Subject: [PATCH] devel and torch dependencies optional --- .github/workflows/test-integration.yml | 2 +- Dockerfile.backend | 2 +- Makefile | 4 +++- pyproject.toml | 27 +++++++++++++++++--------- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 19bacefd..8b1a0b74 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -33,7 +33,7 @@ jobs: run: uv python install 3.13 - name: Install dependencies - run: uv sync + run: uv sync --group dev - name: Run integration tests env: diff --git a/Dockerfile.backend b/Dockerfile.backend index 5d9d84f4..d314eefe 100644 --- a/Dockerfile.backend +++ b/Dockerfile.backend @@ -18,7 +18,7 @@ WORKDIR /app # Copy Python dependencies COPY pyproject.toml uv.lock ./ -RUN uv sync +RUN uv sync --extra torch-cu128 # Copy sample document and warmup script for docling COPY documents/warmup_ocr.pdf ./ diff --git a/Makefile b/Makefile index e9c0367d..eeab5a12 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ install: install-be install-fe install-be: @echo "📦 Installing backend dependencies..." - uv sync + uv sync --extra torch-cu128 install-fe: @echo "📦 Installing frontend dependencies..." @@ -184,6 +184,8 @@ test-integration: # CI-friendly integration test target: brings up infra, waits, runs tests, tears down test-ci: @set -e; \ + echo "📦 Installing test dependencies..."; \ + uv sync --group dev; \ echo "🚀 Starting infra (OpenSearch + Dashboards + Langflow)"; \ make infra; \ echo "⏳ Waiting for OpenSearch..."; \ diff --git a/pyproject.toml b/pyproject.toml index 04200e93..8e816391 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,6 @@ dependencies = [ "pyjwt>=2.8.0", "python-multipart>=0.0.20", "starlette>=0.47.1", - "torch>=2.7.1", "uvicorn>=0.35.0", "boto3>=1.35.0", "psutil>=7.0.0", @@ -27,12 +26,15 @@ dependencies = [ "python-dotenv>=1.0.0", "textual-fspicker>=0.6.0", "structlog>=25.4.0", - "pytest>=8.0.0", - "pytest-asyncio>=0.21.0", - "pytest-mock>=3.12.0", - "pytest-cov>=4.0.0", ] +[project.optional-dependencies] +torch = ["torch", "torchvision"] +torch-cu128 = ["torch", "torchvision"] + +[dependency-groups] +dev = ["pytest>=8", "pytest-asyncio>=0.21.0", "pytest-mock>=3.12.0", "pytest-cov>=4.0.0"] + [project.scripts] openrag = "tui.main:run_tui" @@ -41,13 +43,20 @@ package = true [tool.uv.sources] torch = [ - { index = "pytorch-cu128", marker = "sys_platform == 'linux' and platform_machine == 'x86_64'" }, + { index = "pytorch-cu128", extra = "torch-cu128" }, + { index = "pytorch-cpu", extra = "torch" } ] torchvision = [ - { index = "pytorch-cu128", marker = "sys_platform == 'linux' and platform_machine == 'x86_64'" }, + { index = "pytorch-cu128", extra = "torch-cu128" }, + { index = "pytorch-cpu", extra = "torch" } ] [[tool.uv.index]] -name = "pytorch-cu128" -url = "https://download.pytorch.org/whl/cu128" +name = "pytorch-cu128" +url = "https://download.pytorch.org/whl/cu128" +explicit = true + +[[tool.uv.index]] +name = "pytorch-cpu" +url = "https://download.pytorch.org/whl/cpu" explicit = true