Skip to content

feat: extend RedisVL version support to 0.7.0 #52

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 1 commit into from
May 30, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ We welcome contributions! Here's how you can help:
2. Install dependencies:

```bash
poetry install --all-extras
`poetry install --all-extras`
```

### Available Commands
Expand Down
78 changes: 6 additions & 72 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ packages = [{ include = "langgraph" }]
[tool.poetry.dependencies]
python = ">=3.9,<3.14"
langgraph-checkpoint = "^2.0.24"
redisvl = "^0.5.1"
redisvl = ">=0.5.1,<0.8.0"
redis = "^5.2.1"
python-ulid = "^3.0.0"

Expand Down
28 changes: 25 additions & 3 deletions tests/test_interruption.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InterruptionError(Exception):
pass


class MockRedis:
class MockRedis(Redis):
"""Mock Redis class that can simulate interruptions during operations."""

def __init__(self, real_redis: Redis, interrupt_on: str = None) -> None:
Expand All @@ -34,14 +34,36 @@ def __init__(self, real_redis: Redis, interrupt_on: str = None) -> None:
real_redis: The real Redis client to delegate to
interrupt_on: Operation name to interrupt on (e.g., 'json().set', 'Pipeline.execute')
"""
# Copy connection info from real_redis to satisfy Redis base class
super().__init__(
connection_pool=real_redis.connection_pool,
single_connection_client=real_redis.single_connection_client,
)
self.real_redis = real_redis
self.interrupt_on = interrupt_on
self.operations_count = {}
self.interrupt_after_count = {}

def __getattr__(self, name):
def __getattribute__(self, name):
"""Proxy attribute access to the real Redis client, but track operations."""
attr = getattr(self.real_redis, name)
# For special attributes we've set in __init__, use the parent implementation
if name in [
"real_redis",
"interrupt_on",
"operations_count",
"interrupt_after_count",
]:
return super().__getattribute__(name)

# For Redis base class attributes
if name in ["connection_pool", "single_connection_client", "_parser", "_lock"]:
return super().__getattribute__(name)

try:
attr = getattr(self.real_redis, name)
except AttributeError:
# Fall back to parent class
return super().__getattribute__(name)

# For methods we want to potentially interrupt
if callable(attr) and name == self.interrupt_on:
Expand Down
5 changes: 4 additions & 1 deletion tests/test_shallow_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ def test_from_conn_string_errors(redis_url: str) -> None:
saver.setup()

# Test with empty URL
with pytest.raises(ValueError, match="REDIS_URL env var not set"):
# Handle both old and new RedisVL error message formats
with pytest.raises(
ValueError, match="REDIS_URL (env var|environment variable) not set"
):
with ShallowRedisSaver.from_conn_string("") as saver:
saver.setup()

Expand Down
5 changes: 4 additions & 1 deletion tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,10 @@ def test_from_conn_string_errors() -> None:
saver.setup()

# Test with empty URL
with pytest.raises(ValueError, match="REDIS_URL env var not set"):
# Handle both old and new RedisVL error message formats
with pytest.raises(
ValueError, match="REDIS_URL (env var|environment variable) not set"
):
with RedisSaver.from_conn_string("") as saver:
saver.setup()

Expand Down