test: Update E2E tests to use Pipeline.dump/load (#6756)

This commit is contained in:
Madeesh Kannan
2024-01-17 15:09:27 +01:00
committed by GitHub
parent 88191e74bf
commit 6a1514550e
5 changed files with 25 additions and 29 deletions
+5 -6
View File
@@ -41,14 +41,13 @@ def test_dense_doc_search_pipeline(tmp_path, samples_path):
# Draw the indexing pipeline
indexing_pipeline.draw(tmp_path / "test_dense_doc_search_indexing_pipeline.png")
# Serialize the indexing pipeline to JSON
with open(tmp_path / "test_dense_doc_search_indexing_pipeline.json", "w") as f:
print(json.dumps(indexing_pipeline.to_dict(), indent=4))
json.dump(indexing_pipeline.to_dict(), f)
# Serialize the indexing pipeline to YAML.
with open(tmp_path / "test_dense_doc_search_indexing_pipeline.yaml", "w") as f:
indexing_pipeline.dump(f)
# Load the indexing pipeline back
with open(tmp_path / "test_dense_doc_search_indexing_pipeline.json", "r") as f:
indexing_pipeline = Pipeline.from_dict(json.load(f))
with open(tmp_path / "test_dense_doc_search_indexing_pipeline.yaml", "r") as f:
indexing_pipeline = Pipeline.load(f)
indexing_result = indexing_pipeline.run({"file_type_router": {"sources": list(samples_path.iterdir())}})
filled_document_store = indexing_pipeline.get_component("writer").document_store
+5 -6
View File
@@ -16,14 +16,13 @@ def test_extractive_qa_pipeline(tmp_path):
# Draw the pipeline
qa_pipeline.draw(tmp_path / "test_extractive_qa_pipeline.png")
# Serialize the pipeline to JSON
with open(tmp_path / "test_bm25_rag_pipeline.json", "w") as f:
print(json.dumps(qa_pipeline.to_dict(), indent=4))
json.dump(qa_pipeline.to_dict(), f)
# Serialize the pipeline to YAML
with open(tmp_path / "test_bm25_rag_pipeline.yaml", "w") as f:
qa_pipeline.dump(f)
# Load the pipeline back
with open(tmp_path / "test_bm25_rag_pipeline.json", "r") as f:
qa_pipeline = Pipeline.from_dict(json.load(f))
with open(tmp_path / "test_bm25_rag_pipeline.yaml", "r") as f:
qa_pipeline = Pipeline.load(f)
# Populate the document store
documents = [
@@ -31,14 +31,13 @@ def test_hybrid_doc_search_pipeline(tmp_path):
# Draw the pipeline
hybrid_pipeline.draw(tmp_path / "test_hybrid_doc_search_pipeline.png")
# Serialize the pipeline to JSON
with open(tmp_path / "test_hybrid_doc_search_pipeline.json", "w") as f:
print(json.dumps(hybrid_pipeline.to_dict(), indent=4))
json.dump(hybrid_pipeline.to_dict(), f)
# Serialize the pipeline to YAML
with open(tmp_path / "test_hybrid_doc_search_pipeline.yaml", "w") as f:
hybrid_pipeline.dump(f)
# Load the pipeline back
with open(tmp_path / "test_hybrid_doc_search_pipeline.json", "r") as f:
hybrid_pipeline = Pipeline.from_dict(json.load(f))
with open(tmp_path / "test_hybrid_doc_search_pipeline.yaml", "r") as f:
hybrid_pipeline = Pipeline.load(f)
# Populate the document store
documents = [
+5 -6
View File
@@ -39,14 +39,13 @@ def test_preprocessing_pipeline(tmp_path):
# Draw the pipeline
preprocessing_pipeline.draw(tmp_path / "test_preprocessing_pipeline.png")
# Serialize the pipeline to JSON
with open(tmp_path / "test_preprocessing_pipeline.json", "w") as f:
print(json.dumps(preprocessing_pipeline.to_dict(), indent=4))
json.dump(preprocessing_pipeline.to_dict(), f)
# Serialize the pipeline to YAML
with open(tmp_path / "test_preprocessing_pipeline.yaml", "w") as f:
preprocessing_pipeline.dump(f)
# Load the pipeline back
with open(tmp_path / "test_preprocessing_pipeline.json", "r") as f:
preprocessing_pipeline = Pipeline.from_dict(json.load(f))
with open(tmp_path / "test_preprocessing_pipeline.yaml", "r") as f:
preprocessing_pipeline = Pipeline.load(f)
# Write a txt file
with open(tmp_path / "test_file_english.txt", "w") as f:
+5 -5
View File
@@ -41,13 +41,13 @@ def test_bm25_rag_pipeline(tmp_path):
# Draw the pipeline
rag_pipeline.draw(tmp_path / "test_bm25_rag_pipeline.png")
# Serialize the pipeline to JSON
with open(tmp_path / "test_bm25_rag_pipeline.json", "w") as f:
json.dump(rag_pipeline.to_dict(), f)
# Serialize the pipeline to YAML
with open(tmp_path / "test_bm25_rag_pipeline.yaml", "w") as f:
rag_pipeline.dump(f)
# Load the pipeline back
with open(tmp_path / "test_bm25_rag_pipeline.json", "r") as f:
rag_pipeline = Pipeline.from_dict(json.load(f))
with open(tmp_path / "test_bm25_rag_pipeline.yaml", "r") as f:
rag_pipeline = Pipeline.load(f)
# Populate the document store
documents = [