mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-27 15:08:43 +00:00
feat: change PipelineConfigError to DocumentStoreError with more details (#3783)
This commit is contained in:
parent
19c7725319
commit
b155297a06
@ -46,7 +46,7 @@ from haystack.pipelines.config import (
|
||||
from haystack.pipelines.utils import generate_code, print_eval_report
|
||||
from haystack.utils import DeepsetCloud, calculate_context_similarity
|
||||
from haystack.schema import Answer, EvaluationResult, MultiLabel, Document, Span
|
||||
from haystack.errors import HaystackError, PipelineError, PipelineConfigError
|
||||
from haystack.errors import HaystackError, PipelineError, PipelineConfigError, DocumentStoreError
|
||||
from haystack.nodes import BaseGenerator, Docs2Answers, BaseReader, BaseSummarizer, BaseTranslator, QuestionGenerator
|
||||
from haystack.nodes.base import BaseComponent, RootNode
|
||||
from haystack.nodes.retriever.base import BaseRetriever
|
||||
@ -2022,9 +2022,13 @@ class Pipeline:
|
||||
f"Failed loading pipeline component '{name}': "
|
||||
"seems like the component does not exist. Did you spell its name correctly?"
|
||||
) from ke
|
||||
except ConnectionError as ce:
|
||||
raise DocumentStoreError(f"Failed loading pipeline component '{name}': '{ce}'") from ce
|
||||
except DocumentStoreError as de:
|
||||
raise de
|
||||
except Exception as e:
|
||||
raise PipelineConfigError(
|
||||
f"Failed loading pipeline component '{name}'. " "See the stacktrace above for more informations."
|
||||
f"Failed loading pipeline component '{name}'. See the stacktrace above for more information."
|
||||
) from e
|
||||
|
||||
def save_to_yaml(self, path: Path, return_defaults: bool = False):
|
||||
@ -2152,7 +2156,7 @@ class Pipeline:
|
||||
not_a_node = set(params.keys()) - set(self.graph.nodes)
|
||||
# "debug" will be picked up by _dispatch_run, see its code
|
||||
# "add_isolated_node_eval" is set by pipeline.eval / pipeline.eval_batch
|
||||
valid_global_params = set(["debug", "add_isolated_node_eval"])
|
||||
valid_global_params = {"debug", "add_isolated_node_eval"}
|
||||
for node_id in self.graph.nodes:
|
||||
run_signature_args = self._get_run_node_signature(node_id)
|
||||
valid_global_params |= set(run_signature_args)
|
||||
|
||||
@ -14,7 +14,7 @@ import haystack
|
||||
from haystack import Pipeline
|
||||
from haystack.nodes import _json_schema
|
||||
from haystack.nodes import FileTypeClassifier
|
||||
from haystack.errors import HaystackError, PipelineConfigError, PipelineSchemaError
|
||||
from haystack.errors import HaystackError, PipelineConfigError, PipelineSchemaError, DocumentStoreError
|
||||
from haystack.nodes.base import BaseComponent
|
||||
|
||||
from ..conftest import SAMPLES_PATH, MockNode, MockDocumentStore, MockReader, MockRetriever
|
||||
@ -141,6 +141,46 @@ def test_load_yaml(tmp_path):
|
||||
assert isinstance(pipeline.get_node("reader"), MockReader)
|
||||
|
||||
|
||||
def test_load_yaml_elasticsearch_not_responding(tmp_path):
|
||||
# Test if DocumentStoreError is raised if elasticsearch instance is not responding (due to wrong port)
|
||||
with open(tmp_path / "tmp_config.yml", "w") as tmp_file:
|
||||
tmp_file.write(
|
||||
f"""
|
||||
version: ignore
|
||||
components:
|
||||
- name: ESRetriever
|
||||
type: BM25Retriever
|
||||
params:
|
||||
document_store: DocumentStore
|
||||
- name: DocumentStore
|
||||
type: ElasticsearchDocumentStore
|
||||
params:
|
||||
port: 1234
|
||||
- name: PDFConverter
|
||||
type: PDFToTextConverter
|
||||
- name: Preprocessor
|
||||
type: PreProcessor
|
||||
pipelines:
|
||||
- name: query_pipeline
|
||||
nodes:
|
||||
- name: ESRetriever
|
||||
inputs: [Query]
|
||||
- name: indexing_pipeline
|
||||
nodes:
|
||||
- name: PDFConverter
|
||||
inputs: [File]
|
||||
- name: Preprocessor
|
||||
inputs: [PDFConverter]
|
||||
- name: ESRetriever
|
||||
inputs: [Preprocessor]
|
||||
- name: DocumentStore
|
||||
inputs: [ESRetriever]
|
||||
"""
|
||||
)
|
||||
with pytest.raises(DocumentStoreError):
|
||||
Pipeline.load_from_yaml(path=tmp_path / "tmp_config.yml", pipeline_name="indexing_pipeline")
|
||||
|
||||
|
||||
def test_load_yaml_non_existing_file():
|
||||
with pytest.raises(FileNotFoundError):
|
||||
Pipeline.load_from_yaml(path=SAMPLES_PATH / "pipeline" / "I_dont_exist.yml")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user