Skip to content

Commit

Permalink
Limit milvus-lite files to end with .db (#2214)
Browse files Browse the repository at this point in the history
Signed-off-by: junjie.jiang <[email protected]>
  • Loading branch information
junjiejiangjjj authored Aug 5, 2024
1 parent 3029ed3 commit 9ff4b2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pymilvus/orm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,11 @@ def connect(
"grpc",
]:
# start and connect milvuslite
if kwargs["uri"].endswith("/"):
if not kwargs["uri"].endswith(".db"):
raise ConnectionConfigException(
message=f"Open local milvus failed, {kwargs['uri']} is not a local file path"
message=f"uri: {kwargs['uri']} is illegal, needs start with [unix, http, https, tcp] or a local file endswith [.db]"
)
logger.info(f"Pass in the local path {kwargs['uri']}, and run it using milvus-lite")
parent_path = pathlib.Path(kwargs["uri"]).parent
if not parent_path.is_dir():
raise ConnectionConfigException(
Expand Down
8 changes: 8 additions & 0 deletions tests/test_milvus_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from pymilvus.milvus_client import MilvusClient
from pymilvus.exceptions import ConnectionConfigException


@pytest.mark.skipif(sys.platform.startswith('win'), reason="Milvus Lite is not supported on Windows")
Expand Down Expand Up @@ -56,3 +57,10 @@ def test_milvus_lite(self):
filter="subject == 'history'",
)
assert len(res) == 3

def test_illegal_name(self):
try:
MilvusClient("localhost")
assert False
except ConnectionConfigException as e:
assert e.message == "uri: localhost is illegal, needs start with [unix, http, https, tcp] or a local file endswith [.db]"

0 comments on commit 9ff4b2c

Please sign in to comment.