Skip to content

fix url pass #289

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 2 commits into from
Feb 21, 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
4 changes: 2 additions & 2 deletions redisvl/cli/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def listall(self, args: Namespace):
rvl index listall
"""
redis_url = create_redis_url(args)
conn = RedisConnectionFactory.get_redis_connection(redis_url)
conn = RedisConnectionFactory.get_redis_connection(redis_url=redis_url)
indices = convert_bytes(conn.execute_command("FT._LIST"))
logger.info("Indices:")
for i, index in enumerate(indices):
Expand Down Expand Up @@ -107,7 +107,7 @@ def _connect_to_index(self, args: Namespace) -> SearchIndex:
# connect to redis
try:
redis_url = create_redis_url(args)
conn = RedisConnectionFactory.get_redis_connection(url=redis_url)
conn = RedisConnectionFactory.get_redis_connection(redis_url=redis_url)
except ValueError:
logger.error(
"Must set REDIS_URL environment variable or provide host and port"
Expand Down
2 changes: 1 addition & 1 deletion redisvl/index/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def _redis_client(self) -> Optional[redis.Redis]:
with self._lock:
if self.__redis_client is None:
self.__redis_client = RedisConnectionFactory.get_redis_connection(
url=self._redis_url,
redis_url=self._redis_url,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally I think we should always use redis_url vs url because it's more specific and that's what we tend to say when we do it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

**self._connection_kwargs,
)
return self.__redis_client
Expand Down
4 changes: 2 additions & 2 deletions redisvl/redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def connect(

@staticmethod
def get_redis_connection(
url: Optional[str] = None,
redis_url: Optional[str] = None,
required_modules: Optional[List[Dict[str, Any]]] = None,
**kwargs,
) -> Redis:
Expand All @@ -245,7 +245,7 @@ def get_redis_connection(
variable is not set.
RedisModuleVersionError: If required Redis modules are not installed.
"""
url = url or get_address_from_env()
url = redis_url or get_address_from_env()
client = Redis.from_url(url, **kwargs)

RedisConnectionFactory.validate_sync_redis(
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def client(redis_url):
"""
A sync Redis client that uses the dynamic `redis_url`.
"""
conn = RedisConnectionFactory.get_redis_connection(redis_url)
conn = RedisConnectionFactory.get_redis_connection(redis_url=redis_url)
yield conn


Expand Down
11 changes: 11 additions & 0 deletions tests/integration/test_search_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ def test_search_index_from_existing(client, index):
assert index2.schema == index.schema


def test_search_index_from_existing_url(redis_url, index):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most excellent

index.create(overwrite=True)

try:
index2 = SearchIndex.from_existing(index.name, redis_url=redis_url)
except Exception as e:
pytest.skip(str(e))

assert index2.schema == index.schema


def test_search_index_from_existing_complex(client):
schema = {
"index": {
Expand Down