diff --git a/pymilvus/orm/connections.py b/pymilvus/orm/connections.py index 490d7768c..7855c72e4 100644 --- a/pymilvus/orm/connections.py +++ b/pymilvus/orm/connections.py @@ -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( diff --git a/tests/test_milvus_lite.py b/tests/test_milvus_lite.py index 0149fd5bc..544da9f17 100644 --- a/tests/test_milvus_lite.py +++ b/tests/test_milvus_lite.py @@ -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") @@ -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]"