diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61dd20a..2d6ce40 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9'] + python-version: [ '3.9' ] steps: - name: Checkout code @@ -34,5 +34,17 @@ jobs: - name: Lint run: hatch run lint:all - - name: Run tests + - name: Run Milvus + run: | + wget https://github.com/milvus-io/milvus/releases/download/v2.4.0-rc.1/milvus-standalone-docker-compose.yml -O docker-compose.yml + sudo docker compose up -d + sleep 5 + echo "\nMilvus server started!" + + - name: Run tests run: hatch run cov + + - name: Stop and Remove Milvus + run: | + sudo docker compose down + echo "\nMilvus server stopped and removed!" \ No newline at end of file diff --git a/README.md b/README.md index fbe7c9e..69e706f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![PyPI - Version](https://img.shields.io/pypi/v/milvus-haystack.svg)](https://pypi.org/project/milvus-haystack) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/milvus-haystack.svg)](https://pypi.org/project/milvus-haystack) - ## Installation ```console @@ -11,11 +10,14 @@ pip install milvus-haystack ``` ## Usage -First, to start up a Milvus service, follow the ['Start Milvus'](https://milvus.io/docs/install_standalone-docker.md#Start-Milvus) instructions in the documentation. + +First, to start up a Milvus service, follow +the ['Start Milvus'](https://milvus.io/docs/install_standalone-docker.md#Start-Milvus) instructions in the +documentation. Then, to use the `MilvusDocumentStore` in a Haystack pipeline" -```py +```python from haystack import Document from milvus_haystack import MilvusDocumentStore @@ -33,8 +35,9 @@ document_store.count_documents() # 1 Here are the ways to build index, retrieval, and build rag pipeline respectively. -```py -# Create the indexing Pipeline and index some documents +### Create the indexing Pipeline and index some documents + +```python import glob import os @@ -70,9 +73,11 @@ indexing_pipeline.connect("embedder", "writer") indexing_pipeline.run({"converter": {"sources": file_paths}}) print("Number of documents:", document_store.count_documents()) +``` -# ------------------------------------------------------------------------------------ -# Create the retrieval pipeline and try a query +### Create the retrieval pipeline and try a query + +```python question = "What is Milvus?" retrieval_pipeline = Pipeline() @@ -85,9 +90,11 @@ retrieval_results = retrieval_pipeline.run({"embedder": {"text": question}}) for doc in retrieval_results["retriever"]["documents"]: print(doc.content) print("-" * 10) +``` + +### Create the RAG pipeline and try a query -# ------------------------------------------------------------------------------------ -# Create the RAG pipeline and try a query +```python from haystack.utils import Secret from haystack.components.embedders import SentenceTransformersTextEmbedder from haystack.components.builders import PromptBuilder diff --git a/pyproject.toml b/pyproject.toml index 6f11de2..ee62cd7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,6 @@ dependencies = [ "haystack-ai", "typing_extensions", "pymilvus", - "milvus", ] [project.urls] @@ -177,7 +176,6 @@ module = [ "milvus_haystack.*", "pymilvus.*", "numpy", - "milvus", "pytest.*" ] ignore_missing_imports = true diff --git a/src/milvus_haystack/__about__.py b/src/milvus_haystack/__about__.py index de1a290..cbd11ba 100644 --- a/src/milvus_haystack/__about__.py +++ b/src/milvus_haystack/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2023-present Tuana Celik # # SPDX-License-Identifier: Apache-2.0 -__version__ = "0.0.4" +__version__ = "0.0.5" diff --git a/tests/test_document_store.py b/tests/test_document_store.py index c5222f3..cef74a7 100644 --- a/tests/test_document_store.py +++ b/tests/test_document_store.py @@ -12,24 +12,6 @@ class TestDocumentStore(CountDocumentsTest, WriteDocumentsTest, DeleteDocumentsTest): - from milvus import MilvusServer - - milvus_server = MilvusServer() - milvus_server.set_base_dir("test_milvus_base") - milvus_server.listen_port = 19530 - try: - milvus_server.stop() - except Exception as err: - logger.debug("Can not stop Milvus server. %s", err) - try: - milvus_server.cleanup() - except Exception as err: - logger.debug("Can not cleanup Milvus. %s", err) - try: - milvus_server.start() - except Exception as err: - logger.debug("Can not start Milvus server. %s", err) - @pytest.fixture def document_store(self) -> MilvusDocumentStore: return MilvusDocumentStore( diff --git a/tests/test_embedding_retriever.py b/tests/test_embedding_retriever.py index 4d898f0..0c88538 100644 --- a/tests/test_embedding_retriever.py +++ b/tests/test_embedding_retriever.py @@ -10,24 +10,6 @@ class TestMilvusEmbeddingTests: - from milvus import MilvusServer - - milvus_server = MilvusServer() - milvus_server.set_base_dir("test_milvus_base") - milvus_server.listen_port = 19530 - try: - milvus_server.stop() - except Exception as err: - logger.debug("Can not stop Milvus server. %s", err) - try: - milvus_server.cleanup() - except Exception as err: - logger.debug("Can not cleanup Milvus. %s", err) - try: - milvus_server.start() - except Exception as err: - logger.debug("Can not start Milvus server. %s", err) - @pytest.fixture def document_store(self) -> MilvusDocumentStore: return MilvusDocumentStore( diff --git a/tests/test_filters.py b/tests/test_filters.py index b7a82da..3598152 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -12,24 +12,6 @@ class TestMilvusFilters(FilterDocumentsTest): - from milvus import MilvusServer - - milvus_server = MilvusServer() - milvus_server.set_base_dir("test_milvus_base") - milvus_server.listen_port = 19530 - try: - milvus_server.stop() - except Exception as err: - logger.debug("Can not stop Milvus server. %s", err) - try: - milvus_server.cleanup() - except Exception as err: - logger.debug("Can not cleanup Milvus. %s", err) - try: - milvus_server.start() - except Exception as err: - logger.debug("Can not start Milvus server. %s", err) - @pytest.fixture def filterable_docs(self) -> List[Document]: documents = []