@@ -152,75 +152,8 @@ def test_hybrid_rag_pipeline_crash_on_embedding_retriever(
152
152
},
153
153
)
154
154
155
- pipeline_outputs = exc_info .value .pipeline_outputs
156
-
157
- assert pipeline_outputs is not None , "Pipeline outputs should be captured in the exception"
158
-
159
- # verify that bm25_retriever and text_embedder ran successfully before the crash
160
- assert "bm25_retriever" in pipeline_outputs , "BM25 retriever output not captured"
161
- assert "documents" in pipeline_outputs ["bm25_retriever" ], "BM25 retriever should have produced documents"
162
- assert "text_embedder" in pipeline_outputs , "Text embedder output not captured"
163
- assert "embedding" in pipeline_outputs ["text_embedder" ], "Text embedder should have produced embeddings"
164
-
165
- # components after the crash point are not in the outputs
166
- assert "document_joiner" not in pipeline_outputs , "Document joiner should not have run due to crash"
167
- assert "prompt_builder" not in pipeline_outputs , "Prompt builder should not have run due to crash"
168
- assert "llm" not in pipeline_outputs , "LLM should not have run due to crash"
169
- assert "answer_builder" not in pipeline_outputs , "Answer builder should not have run due to crash"
170
-
171
- @pytest .mark .asyncio
172
- async def test_async_hybrid_rag_pipeline_crash_on_embedding_retriever (
173
- self , mock_sentence_transformers_text_embedder , monkeypatch
174
- ):
175
- monkeypatch .setenv ("OPENAI_API_KEY" , "test-api-key" )
176
-
177
- document_store = setup_document_store ()
178
- text_embedder = mock_sentence_transformers_text_embedder
179
- invalid_embedding_retriever = InvalidOutputEmbeddingRetriever ()
180
- bm25_retriever = InMemoryBM25Retriever (document_store )
181
- document_joiner = DocumentJoiner (join_mode = "concatenate" )
182
-
183
- pipeline = AsyncPipeline ()
184
- pipeline .add_component ("text_embedder" , text_embedder )
185
- pipeline .add_component ("embedding_retriever" , invalid_embedding_retriever )
186
- pipeline .add_component ("bm25_retriever" , bm25_retriever )
187
- pipeline .add_component ("document_joiner" , document_joiner )
188
- pipeline .add_component (
189
- "prompt_builder" , ChatPromptBuilder (template = template , required_variables = ["question" , "documents" ])
190
- )
191
- pipeline .add_component ("llm" , OpenAIChatGenerator (api_key = Secret .from_env_var ("OPENAI_API_KEY" )))
192
- pipeline .add_component ("answer_builder" , AnswerBuilder ())
193
-
194
- pipeline .connect ("text_embedder" , "embedding_retriever" )
195
- pipeline .connect ("bm25_retriever" , "document_joiner" )
196
- pipeline .connect ("embedding_retriever" , "document_joiner" )
197
- pipeline .connect ("document_joiner.documents" , "prompt_builder.documents" )
198
- pipeline .connect ("prompt_builder" , "llm" )
199
- pipeline .connect ("llm.replies" , "answer_builder.replies" )
200
-
201
- question = "Where does Mark live?"
202
- test_data = {
203
- "text_embedder" : {"text" : question },
204
- "bm25_retriever" : {"query" : question },
205
- "prompt_builder" : {"question" : question },
206
- "answer_builder" : {"query" : question },
207
- }
208
-
209
- with pytest .raises (PipelineRuntimeError ) as exc_info :
210
- await pipeline .run_async (
211
- data = test_data ,
212
- include_outputs_from = {
213
- "text_embedder" ,
214
- "embedding_retriever" ,
215
- "bm25_retriever" ,
216
- "document_joiner" ,
217
- "prompt_builder" ,
218
- "llm" ,
219
- "answer_builder" ,
220
- },
221
- )
222
-
223
- pipeline_outputs = exc_info .value .pipeline_outputs
155
+ pipeline_snapshot = exc_info .value .pipeline_snapshot
156
+ pipeline_outputs = pipeline_snapshot .pipeline_state .pipeline_outputs
224
157
assert pipeline_outputs is not None , "Pipeline outputs should be captured in the exception"
225
158
226
159
# verify that bm25_retriever and text_embedder ran successfully before the crash
@@ -234,7 +167,3 @@ async def test_async_hybrid_rag_pipeline_crash_on_embedding_retriever(
234
167
assert "prompt_builder" not in pipeline_outputs , "Prompt builder should not have run due to crash"
235
168
assert "llm" not in pipeline_outputs , "LLM should not have run due to crash"
236
169
assert "answer_builder" not in pipeline_outputs , "Answer builder should not have run due to crash"
237
-
238
- # check that a pipeline snapshot file was created in the "pipeline_snapshot" directory
239
- snapshot_files = os .listdir (_get_output_dir ("pipeline_snapshot" ))
240
- assert any (f .endswith (".json" ) for f in snapshot_files ), "No pipeline snapshot file found in debug directory"
0 commit comments