Skip to content

Commit

Permalink
try to start milvus serving in workflow job instead of milvus lite
Browse files Browse the repository at this point in the history
Signed-off-by: ChengZi <[email protected]>
  • Loading branch information
zc277584121 committed Mar 29, 2024
1 parent cf0a1f8 commit c25f20d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 67 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']
python-version: [ '3.9' ]

steps:
- name: Checkout code
Expand All @@ -34,5 +34,11 @@ 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
- name: Run tests
run: hatch run cov
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
[![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
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

Expand All @@ -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

Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies = [
"haystack-ai",
"typing_extensions",
"pymilvus",
"milvus",
]

[project.urls]
Expand Down Expand Up @@ -177,7 +176,6 @@ module = [
"milvus_haystack.*",
"pymilvus.*",
"numpy",
"milvus",
"pytest.*"
]
ignore_missing_imports = true
18 changes: 0 additions & 18 deletions tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 0 additions & 18 deletions tests/test_embedding_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 0 additions & 18 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit c25f20d

Please sign in to comment.