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

[cherry-pick] Limit milvus-lite files to end with .db #2216

Merged
merged 1 commit into from
Aug 5, 2024
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
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]"