Skip to content
Closed
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
4 changes: 4 additions & 0 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
- stable
- 'jc/**'

concurrency:
group: e2e-${{ github.ref }}
cancel-in-progress: true

jobs:
cypress-run:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
-e POSTGRES_HOST=postgres \
-e POSTGRES_PASSWORD=PdwPNS2mDN73Vfbc \
-e POSTGRES_DB=polis-test \
-e SKIP_GOLDEN=1 \
delphi \
bash -c " \
set -e; \
Expand Down
14 changes: 14 additions & 0 deletions .spr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
githubRepoOwner: compdemocracy
githubRepoName: polis
githubHost: github.com
githubRemote: origin
githubBranch: edge
requireChecks: true
requireApproval: true
defaultReviewers: []
mergeMethod: squash
mergeQueue: false
prTemplateType: stack
forceFetchTags: false
showPrTitlesInStack: false
branchPushIndividually: false
29 changes: 19 additions & 10 deletions delphi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV UV_SYSTEM_PYTHON=1

# Install uv for faster package installation (~2x faster than pip)
# Placed in /opt/uv (not /usr/local/bin) to avoid leaking into the final/prod image
# via the blanket COPY --from=builder /usr/local/bin in Stage 2.
COPY --from=ghcr.io/astral-sh/uv:0.11.2 /uv /opt/uv/uv
ENV PATH="/opt/uv:$PATH"

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand All @@ -28,21 +35,21 @@
COPY pyproject.toml requirements.lock ./

# Install dependencies from lock file (cached layer - reused unless requirements.lock changes)
# BuildKit cache mount keeps pip cache between builds for faster rebuilds
# BuildKit cache mount keeps uv cache between builds for faster rebuilds
# If USE_CPU_TORCH is true, we install CPU-specific wheels and filter them out of the lockfile
RUN --mount=type=cache,target=/root/.cache/pip \
RUN --mount=type=cache,target=/root/.cache/uv \
if [ "$USE_CPU_TORCH" = "true" ]; then \
echo "USE_CPU_TORCH=true: Installing CPU-only PyTorch..." && \
pip install --index-url https://download.pytorch.org/whl/cpu \
uv pip install --index-url https://download.pytorch.org/whl/cpu \
torch==2.8.0 \
torchvision==0.23.0 \
torchaudio==2.8.0 && \
echo "Filtering standard torch packages from requirements.lock..." && \
grep -vE "^(torch|torchvision|torchaudio)==" requirements.lock > requirements.filtered.lock && \
pip install -r requirements.filtered.lock; \
uv pip install -r requirements.filtered.lock; \
else \
echo "USE_CPU_TORCH=false: Installing standard dependencies..." && \
pip install -r requirements.lock; \
uv pip install -r requirements.lock; \
fi

# ===== OPTIMIZATION: Copy source code LAST (busts cache on code changes) =====
Expand All @@ -54,8 +61,8 @@ RUN --mount=type=cache,target=/root/.cache/pip \

# Install the project package (without dependencies - they're already installed)
# This registers entry points and installs the package in development mode
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-deps .
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install --no-deps .

RUN echo "--- PyTorch Check (after pyproject.toml installation) ---" && \
pip show torch torchvision torchaudio && \
Expand Down Expand Up @@ -132,12 +139,14 @@ RUN apt-get update && \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Copy pyproject.toml to install dev dependencies
# Copy uv from builder for faster package installation
COPY --from=builder /opt/uv/uv /usr/local/bin/uv
ENV UV_SYSTEM_PYTHON=1
COPY pyproject.toml .

# Install dev dependencies (pytest, etc.) using caching
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir ".[dev]"
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install ".[dev]"

# Default command for test container (can be overridden)
CMD ["tail", "-f", "/dev/null"]
9 changes: 9 additions & 0 deletions delphi/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
pytest tests/test_regression.py --include-local # Include local datasets
"""

import os

import pytest
import numpy as np

from polismath.regression import ConversationRecorder, ConversationComparer
from polismath.regression.utils import load_golden_snapshot

_skip_golden = pytest.mark.skipif(
os.environ.get("SKIP_GOLDEN") == "1",
reason="Golden snapshot tests disabled (SKIP_GOLDEN=1)",
)


def _check_golden_exists(dataset_name: str):
"""
Expand All @@ -44,6 +51,7 @@ def _check_golden_exists(dataset_name: str):
)


@_skip_golden
@pytest.mark.use_discovered_datasets
def test_conversation_regression(dataset_name):
"""
Expand Down Expand Up @@ -91,6 +99,7 @@ def test_conversation_regression(dataset_name):
)


@_skip_golden
@pytest.mark.use_discovered_datasets
def test_conversation_stages_individually(dataset_name):
"""
Expand Down
Loading