Skip to content

Commit

Permalink
Limit milvus-lite files to end with .db
Browse files Browse the repository at this point in the history
Signed-off-by: junjie.jiang <[email protected]>
  • Loading branch information
junjiejiangjjj committed Aug 5, 2024
1 parent 5bf0a24 commit 1040598
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pymilvus/orm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,11 @@ def connect(
"tcp",
]:
# 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]"
)

parent_path = pathlib.Path(kwargs["uri"]).parent
if not parent_path.is_dir():
raise ConnectionConfigException(
Expand All @@ -377,6 +378,7 @@ def connect(

from milvus_lite.server_manager import server_manager_instance

logger.info(f"Pass in the local path {kwargs['uri']}, and run it using milvus-lite")
local_uri = server_manager_instance.start_and_get_uri(kwargs["uri"])
if local_uri is None:
raise ConnectionConfigException(message="Open local milvus failed")
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 1040598

Please sign in to comment.