Skip to content

Commit

Permalink
Added tests with milvus lite
Browse files Browse the repository at this point in the history
  • Loading branch information
bsuryadevara committed Oct 11, 2023
1 parent e4b8a02 commit a5e742e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
11 changes: 6 additions & 5 deletions morpheus/service/milvus_vector_db_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,16 @@ def create(self, name: str, overwrite: bool = False, **kwargs: dict[str, typing.
self._client.create_partition(collection_name=name, partition_name=part["name"], timeout=timeout)

@with_collection_lock
def insert(self, name: str, data: typing.Any, **kwargs: dict[str, typing.Any]) -> dict:
def insert(self, name: str, data: typing.Union[list[list], list[dict], dict], **kwargs: dict[str,
typing.Any]) -> dict:
"""
Insert a collection specific data in the Milvus vector database.
Parameters
----------
name : str
Name of the collection to be inserted.
data : typing.Any
data : typing.Union[list[list], list[dict], dict]
Data to be inserted in the collection.
**kwargs : dict[str, typing.Any]
Additional keyword arguments containing collection configuration.
Expand Down Expand Up @@ -436,7 +437,7 @@ def delete_by_keys(self, name: str, keys: typing.Union[int, str, list], **kwargs
----------
name : str
Name of the resource.
keys : typing.Any
keys : typing.Union[int, str, list]
Primary keys to delete vectors.
**kwargs : dict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
Expand All @@ -452,15 +453,15 @@ def delete_by_keys(self, name: str, keys: typing.Union[int, str, list], **kwargs
return response

@with_collection_lock
def delete(self, name: str, expr: str, **kwargs: dict[str, typing.Any]) -> typing.Any:
def delete(self, name: str, expr: typing.Union[str, dict], **kwargs: dict[str, typing.Any]) -> typing.Any:
"""
Delete vectors from the resource using expressions.
Parameters
----------
name : str
Name of the resource.
expr : str
expr : typing.Union[str, dict]
Delete expression.
**kwargs : dict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
Expand Down
17 changes: 10 additions & 7 deletions morpheus/service/vector_db_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ class VectorDBService(ABC):
"""

@abstractmethod
def insert(self, name: str, data: typing.Any, **kwargs: dict[str, typing.Any]) -> dict:
def insert(self, name: str, data: typing.Union[list[list], list[dict], dict], **kwargs: dict[str,
typing.Any]) -> dict:
"""
Insert data into the vector database.
Parameters
----------
name : str
Name of the resource.
data : typing.Any
data : typing.Union[list[list], list[dict], dict]
Data to be inserted into the resource.
**kwargs : dict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
Expand Down Expand Up @@ -140,13 +141,13 @@ def update(self, name: str, data: typing.Any, **kwargs: dict[str, typing.Any]) -
pass

@abstractmethod
def delete(self, name: str, expr: typing.Any, **kwargs: dict[str, typing.Any]) -> None:
def delete(self, name: str, expr: typing.Union[str, dict], **kwargs: dict[str, typing.Any]) -> None:
"""
Delete data in the vector database.
Parameters
----------
name : str
name : typing.Union[str, dict]
Name of the resource.
expr : typing.Any
E.
Expand Down Expand Up @@ -257,7 +258,8 @@ def transform(self, data: typing.Any, **kwargs: dict[str, typing.Any]) -> typing
return data

@abstractmethod
def retrieve_by_keys(self, name: str, keys: typing.Any, **kwargs: dict[str, typing.Any]) -> typing.Any:
def retrieve_by_keys(self, name: str, keys: typing.Union[int, str, list], **kwargs: dict[str,
typing.Any]) -> typing.Any:
"""
Retrieve the inserted vectors using keys from the resource.
Expand All @@ -278,15 +280,16 @@ def retrieve_by_keys(self, name: str, keys: typing.Any, **kwargs: dict[str, typi
pass

@abstractmethod
def delete_by_keys(self, name: str, keys: typing.Any, **kwargs: dict[str, typing.Any]) -> typing.Any:
def delete_by_keys(self, name: str, keys: typing.Union[int, str, list], **kwargs: dict[str,
typing.Any]) -> typing.Any:
"""
Delete vectors by keys from the resource.
Parameters
----------
name : str
Name of the resource.
keys : typing.Any
keys : typing.Union[int, str, list]
Primary keys to delete vectors.
**kwargs : dict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
Expand Down

0 comments on commit a5e742e

Please sign in to comment.