Skip to content

Commit

Permalink
Add IT test for deploying pipeline, check status and open /docs route
Browse files Browse the repository at this point in the history
  • Loading branch information
mpangrazzi committed Dec 11, 2024
1 parent 730bb7e commit 425f0ae
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 50 deletions.
72 changes: 72 additions & 0 deletions tests/test_files/basic_rag_pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
components:
llm:
init_parameters:
api_base_url: null
api_key:
env_vars:
- OPENAI_API_KEY
strict: true
type: env_var
generation_kwargs: {}
model: gpt-4o-mini
organization: null
streaming_callback: null
system_prompt: null
type: haystack.components.generators.openai.OpenAIGenerator
prompt_builder:
init_parameters:
required_variables: null
template: "\nGiven the following information, answer the question.\n\nContext:\n\
{% for document in documents %}\n {{ document.content }}\n{% endfor %}\n\
\nQuestion: {{question}}\nAnswer:\n"
variables: null
type: haystack.components.builders.prompt_builder.PromptBuilder
retriever:
init_parameters:
document_store:
init_parameters:
bm25_algorithm: BM25L
bm25_parameters: {}
bm25_tokenization_regex: (?u)\b\w\w+\b
embedding_similarity_function: dot_product
index: d8b1f58f-20e9-4a57-a84d-a44fc651de4e
type: haystack.document_stores.in_memory.document_store.InMemoryDocumentStore
filter_policy: replace
filters: null
return_embedding: false
scale_score: false
top_k: 10
type: haystack.components.retrievers.in_memory.embedding_retriever.InMemoryEmbeddingRetriever
text_embedder:
init_parameters:
batch_size: 32
config_kwargs: null
device:
device: mps
type: single
model: sentence-transformers/all-MiniLM-L6-v2
model_kwargs: null
normalize_embeddings: false
precision: float32
prefix: ''
progress_bar: true
suffix: ''
token:
env_vars:
- HF_API_TOKEN
- HF_TOKEN
strict: false
type: env_var
tokenizer_kwargs: null
truncate_dim: null
trust_remote_code: false
type: haystack.components.embedders.sentence_transformers_text_embedder.SentenceTransformersTextEmbedder
connections:
- receiver: retriever.query_embedding
sender: text_embedder.embedding
- receiver: prompt_builder.documents
sender: retriever.documents
- receiver: llm.prompt
sender: prompt_builder.prompt
max_runs_per_component: 100
metadata: {}
50 changes: 0 additions & 50 deletions tests/test_files/chat_with_website.yaml

This file was deleted.

46 changes: 46 additions & 0 deletions tests/test_files/pipeline_qdrant_2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
components:
document_embedder:
init_parameters:
batch_size: 32
config_kwargs: null
device:
device: cpu
type: single
model: sentence-transformers/paraphrase-MiniLM-L3-v2
model_kwargs: null
normalize_embeddings: false
precision: float32
prefix: ''
progress_bar: true
suffix: ''
token:
env_vars:
- HF_API_TOKEN
- HF_TOKEN
strict: false
type: env_var
tokenizer_kwargs: null
truncate_dim: null
trust_remote_code: false
type: haystack.components.embedders.sentence_transformers_text_embedder.SentenceTransformersTextEmbedder
document_retriever:
init_parameters:
document_store:
init_parameters:
bm25_algorithm: BM25L
bm25_parameters: {}
bm25_tokenization_regex: (?u)\b\w\w+\b
embedding_similarity_function: dot_product
index: b39f1fea-7c83-4fdc-a9e0-928e3d5e4ae7
type: haystack.document_stores.in_memory.document_store.InMemoryDocumentStore
filter_policy: replace
filters: null
return_embedding: false
scale_score: false
top_k: 3
type: haystack.components.retrievers.in_memory.embedding_retriever.InMemoryEmbeddingRetriever
connections:
- receiver: document_retriever.query_embedding
sender: document_embedder.embedding
max_runs_per_component: 100
metadata: {}
46 changes: 46 additions & 0 deletions tests/test_files/st_retriever.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
components:
document_embedder:
init_parameters:
batch_size: 32
config_kwargs: null
device:
device: cpu
type: single
model: sentence-transformers/paraphrase-MiniLM-L3-v2
model_kwargs: null
normalize_embeddings: false
precision: float32
prefix: ''
progress_bar: true
suffix: ''
token:
env_vars:
- HF_API_TOKEN
- HF_TOKEN
strict: false
type: env_var
tokenizer_kwargs: null
truncate_dim: null
trust_remote_code: false
type: haystack.components.embedders.sentence_transformers_text_embedder.SentenceTransformersTextEmbedder
document_retriever:
init_parameters:
document_store:
init_parameters:
bm25_algorithm: BM25L
bm25_parameters: {}
bm25_tokenization_regex: (?u)\b\w\w+\b
embedding_similarity_function: dot_product
index: b39f1fea-7c83-4fdc-a9e0-928e3d5e4ae7
type: haystack.document_stores.in_memory.document_store.InMemoryDocumentStore
filter_policy: replace
filters: null
return_embedding: false
scale_score: false
top_k: 3
type: haystack.components.retrievers.in_memory.embedding_retriever.InMemoryEmbeddingRetriever
connections:
- receiver: document_retriever.query_embedding
sender: document_embedder.embedding
max_runs_per_component: 100
metadata: {}
24 changes: 24 additions & 0 deletions tests/test_it_deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
from fastapi.testclient import TestClient
from hayhooks.server import app
from pathlib import Path

client = TestClient(app)

# Load pipeline definitions from test_files
test_files = Path(__file__).parent / "test_files"
pipeline_names = [file.stem for file in test_files.glob("*.yml")]


@pytest.mark.parametrize("pipeline_name", pipeline_names)
def test_deploy_pipeline_def(pipeline_name: str):
pipeline_def = (Path(__file__).parent / "test_files" / f"{pipeline_name}.yml").read_text()

deploy_response = client.post("/deploy", json={"name": pipeline_name, "source_code": pipeline_def})
assert deploy_response.status_code == 200

status_response = client.get("/status")
assert pipeline_name in status_response.json()["pipelines"]

docs_response = client.get("/docs")
assert docs_response.status_code == 200

0 comments on commit 425f0ae

Please sign in to comment.