Skip to content

Commit cd5f5bd

Browse files
committed
feat: extend RedisVL version support to 0.7.0
- Update RedisVL dependency constraint from ^0.5.1 to >=0.5.1,<0.8.0 - Fix test compatibility to handle error message changes between RedisVL versions - Update MockRedis class to inherit from Redis base class for RedisVL 0.7.0 type checking - Ensure backwards compatibility with RedisVL 0.5.1 through 0.7.x The library now supports the latest RedisVL 0.7.0 while maintaining compatibility with older versions. Tests use regex patterns to handle different error message formats across RedisVL versions.
1 parent 8321509 commit cd5f5bd

File tree

6 files changed

+41
-79
lines changed

6 files changed

+41
-79
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ We welcome contributions! Here's how you can help:
327327
2. Install dependencies:
328328

329329
```bash
330-
poetry install --all-extras
330+
`poetry install --all-extras`
331331
```
332332

333333
### Available Commands

poetry.lock

Lines changed: 6 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ packages = [{ include = "langgraph" }]
2020
[tool.poetry.dependencies]
2121
python = ">=3.9,<3.14"
2222
langgraph-checkpoint = "^2.0.24"
23-
redisvl = "^0.5.1"
23+
redisvl = ">=0.5.1,<0.8.0"
2424
redis = "^5.2.1"
2525
python-ulid = "^3.0.0"
2626

tests/test_interruption.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class InterruptionError(Exception):
2424
pass
2525

2626

27-
class MockRedis:
27+
class MockRedis(Redis):
2828
"""Mock Redis class that can simulate interruptions during operations."""
2929

3030
def __init__(self, real_redis: Redis, interrupt_on: str = None) -> None:
@@ -34,14 +34,36 @@ def __init__(self, real_redis: Redis, interrupt_on: str = None) -> None:
3434
real_redis: The real Redis client to delegate to
3535
interrupt_on: Operation name to interrupt on (e.g., 'json().set', 'Pipeline.execute')
3636
"""
37+
# Copy connection info from real_redis to satisfy Redis base class
38+
super().__init__(
39+
connection_pool=real_redis.connection_pool,
40+
single_connection_client=real_redis.single_connection_client,
41+
)
3742
self.real_redis = real_redis
3843
self.interrupt_on = interrupt_on
3944
self.operations_count = {}
4045
self.interrupt_after_count = {}
4146

42-
def __getattr__(self, name):
47+
def __getattribute__(self, name):
4348
"""Proxy attribute access to the real Redis client, but track operations."""
44-
attr = getattr(self.real_redis, name)
49+
# For special attributes we've set in __init__, use the parent implementation
50+
if name in [
51+
"real_redis",
52+
"interrupt_on",
53+
"operations_count",
54+
"interrupt_after_count",
55+
]:
56+
return super().__getattribute__(name)
57+
58+
# For Redis base class attributes
59+
if name in ["connection_pool", "single_connection_client", "_parser", "_lock"]:
60+
return super().__getattribute__(name)
61+
62+
try:
63+
attr = getattr(self.real_redis, name)
64+
except AttributeError:
65+
# Fall back to parent class
66+
return super().__getattribute__(name)
4567

4668
# For methods we want to potentially interrupt
4769
if callable(attr) and name == self.interrupt_on:

tests/test_shallow_sync.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ def test_from_conn_string_errors(redis_url: str) -> None:
269269
saver.setup()
270270

271271
# Test with empty URL
272-
with pytest.raises(ValueError, match="REDIS_URL env var not set"):
272+
# Handle both old and new RedisVL error message formats
273+
with pytest.raises(
274+
ValueError, match="REDIS_URL (env var|environment variable) not set"
275+
):
273276
with ShallowRedisSaver.from_conn_string("") as saver:
274277
saver.setup()
275278

tests/test_sync.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,10 @@ def test_from_conn_string_errors() -> None:
451451
saver.setup()
452452

453453
# Test with empty URL
454-
with pytest.raises(ValueError, match="REDIS_URL env var not set"):
454+
# Handle both old and new RedisVL error message formats
455+
with pytest.raises(
456+
ValueError, match="REDIS_URL (env var|environment variable) not set"
457+
):
455458
with RedisSaver.from_conn_string("") as saver:
456459
saver.setup()
457460

0 commit comments

Comments
 (0)