2021-08-02 14:51:24 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import pytest
|
2021-08-31 10:14:55 +02:00
|
|
|
import ray
|
|
|
|
|
2021-08-02 14:51:24 +02:00
|
|
|
from haystack.pipeline import RayPipeline
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("document_store_with_docs", ["elasticsearch"], indirect=True)
|
|
|
|
def test_load_pipeline(document_store_with_docs):
|
|
|
|
pipeline = RayPipeline.load_from_yaml(
|
2021-08-31 10:14:55 +02:00
|
|
|
Path("samples/pipeline/test_pipeline.yaml"), pipeline_name="ray_query_pipeline", num_cpus=8,
|
2021-08-02 14:51:24 +02:00
|
|
|
)
|
|
|
|
prediction = pipeline.run(query="Who lives in Berlin?", top_k_retriever=10, top_k_reader=3)
|
2021-08-31 10:14:55 +02:00
|
|
|
|
|
|
|
assert ray.serve.get_deployment(name="ESRetriever").num_replicas == 2
|
|
|
|
assert ray.serve.get_deployment(name="Reader").num_replicas == 1
|
2021-08-02 14:51:24 +02:00
|
|
|
assert prediction["query"] == "Who lives in Berlin?"
|
|
|
|
assert prediction["answers"][0]["answer"] == "Carla"
|