Skip to content
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

feat: make the KV store configurable via env vars #391

Merged
merged 8 commits into from
Nov 28, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix Redis creation
  • Loading branch information
masci committed Nov 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7b3b6f4616e54b5b70b758279e30214628810983
2 changes: 1 addition & 1 deletion llama_deploy/control_plane/config.py
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ def parse_state_store_uri(uri: str) -> BaseKVStore:
try:
from llama_index.storage.kvstore.redis import RedisKVStore # type: ignore

return RedisKVStore(uri=uri)
return RedisKVStore(redis_uri=uri)
except ImportError:
msg = (
f"key-value store {bits.scheme} is not available, please install the required "
23 changes: 7 additions & 16 deletions tests/control_plane/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Any
from unittest import mock

import pytest
@@ -20,13 +19,9 @@ def test_parse_state_store_uri_malformed() -> None:
parse_state_store_uri("foo://user:pass@host/database")


def test_parse_state_store_uri_redis_not_installed(monkeypatch: Any) -> None:
try:
# Ensure the module is never available, even if the package is installed
monkeypatch.delattr("llama_index.storage.kvstore.redis")
except Exception:
pass

# Ensure the module is never available, even if the package is installed
@mock.patch.dict("sys.modules", {"llama_index.storage.kvstore.redis": None})
def test_parse_state_store_uri_redis_not_installed() -> None:
with pytest.raises(
ValueError, match="pip install llama-index-storage-kvstore-redis"
):
@@ -42,16 +37,12 @@ def test_parse_state_store_uri_redis() -> None:
parse_state_store_uri("redis://localhost/")
calls = redis_mock.mock_calls
assert len(calls) == 1
assert calls[0].kwargs == {"uri": "redis://localhost/"}

assert calls[0].kwargs == {"redis_uri": "redis://localhost/"}

def test_parse_state_store_uri_mongodb_not_installed(monkeypatch: Any) -> None:
try:
# Ensure the module is never available, even if the package is installed
monkeypatch.delattr("llama_index.storage.kvstore.mongodb")
except Exception:
pass

# Ensure the module is never available, even if the package is installed
@mock.patch.dict("sys.modules", {"llama_index.storage.kvstore.mongodb": None})
def test_parse_state_store_uri_mongodb_not_installed() -> None:
with pytest.raises(
ValueError, match="pip install llama-index-storage-kvstore-mongodb"
):
Loading