Skip to content

Support Redis 8 #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 13, 2025
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
25 changes: 12 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@ env:

jobs:
test:
name: Python ${{ matrix.python-version }} - ${{ matrix.connection }} [redis-stack ${{matrix.redis-stack-version}}]
name: Python ${{ matrix.python-version }} - ${{ matrix.connection }} [redis ${{ matrix.redis-version }}]
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]
connection: ['hiredis', 'plain']
redis-stack-version: ['6.2.6-v9', 'latest', 'edge']

services:
redis:
image: redis/redis-stack-server:${{matrix.redis-stack-version}}
ports:
- 6379:6379
redis-version: ['6.2.6-v9', 'latest', '8.0-M03']

steps:
- name: Check out repository
Expand All @@ -58,17 +52,21 @@ jobs:
run: |
poetry add hiredis

- name: Set Redis version
- name: Set Redis image name
run: |
echo "REDIS_VERSION=${{ matrix.redis-stack-version }}" >> $GITHUB_ENV
if [[ "${{ matrix.redis-version }}" == "8.0-M03" ]]; then
echo "REDIS_IMAGE=redis:${{ matrix.redis-version }}" >> $GITHUB_ENV
else
echo "REDIS_IMAGE=redis/redis-stack-server:${{ matrix.redis-version }}" >> $GITHUB_ENV
fi

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}

- name: Run tests
if: matrix.connection == 'plain' && matrix.redis-stack-version == 'latest'
if: matrix.connection == 'plain' && matrix.redis-version == 'latest'
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }}
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
Expand All @@ -86,12 +84,12 @@ jobs:
make test-all

- name: Run tests
if: matrix.connection != 'plain' || matrix.redis-stack-version != 'latest'
if: matrix.connection != 'plain' || matrix.redis-version != 'latest'
run: |
make test

- name: Run notebooks
if: matrix.connection == 'plain' && matrix.redis-stack-version == 'latest'
if: matrix.connection == 'plain' && matrix.redis-version == 'latest'
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }}
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
Expand All @@ -106,6 +104,7 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
docker run -d --name redis -p 6379:6379 redis/redis-stack-server:latest
make test-notebooks

docs:
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def redis_container(request):

# Set the Compose project name so containers do not clash across workers
os.environ["COMPOSE_PROJECT_NAME"] = f"redis_test_{worker_id}"
os.environ.setdefault("REDIS_VERSION", "edge")
os.environ.setdefault("REDIS_IMAGE", "redis/redis-stack-server:latest")

compose = DockerCompose(
context="tests",
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"
services:
redis:
image: "redis/redis-stack:${REDIS_VERSION}"
image: "${REDIS_IMAGE}"
ports:
- "6379"
environment:
Expand Down
21 changes: 14 additions & 7 deletions tests/integration/test_llmcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def test_complex_filters(cache_with_filters):
assert len(results) == 1


def test_index_updating(redis_url):
def test_cache_index_overwrite(redis_url):
cache_no_tags = SemanticCache(
name="test_cache",
redis_url=redis_url,
Expand All @@ -785,15 +785,22 @@ def test_index_updating(redis_url):
# filterable_fields not defined in schema, so no tags will match
tag_filter = Tag("some_tag") == "abc"

response = cache_no_tags.check(
prompt="this prompt has a tag",
filter_expression=tag_filter,
)
try:
response = cache_no_tags.check(
prompt="this prompt has a tag",
filter_expression=tag_filter,
)
except Exception as e:
# This will fail in Redis 8+ on query dialect 2
if "Unknown field" in str(e):
response = []
else:
raise

assert response == []

with pytest.raises((RedisModuleVersionError, ValueError)):

cache_with_tags = SemanticCache(
SemanticCache(
name="test_cache",
redis_url=redis_url,
filterable_fields=[{"name": "some_tag", "type": "tag"}],
Expand Down