Skip to content

Commit cadfee1

Browse files
authored
refactor: Refactor experimental Pipeline to use inheritancee (#323)
* Remove PipelineBase since it's not modified * Use inheritance * Remove unused import * Don't make resume_state and debug_path attributes * Add back minimal pipelinebase * Formatting
1 parent 7a82056 commit cadfee1

9 files changed

Lines changed: 43 additions & 1906 deletions

File tree

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
22
#
33
# SPDX-License-Identifier: Apache-2.0
4-
5-
from .pipeline.base import ComponentPriority, PipelineBase
6-
7-
__all__ = ["PipelineBase"]

haystack_experimental/core/errors.py

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2,93 +2,7 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
from typing import Any, Dict, Optional, Type
6-
7-
8-
class PipelineError(Exception):
9-
pass
10-
11-
12-
class PipelineRuntimeError(Exception):
13-
def __init__(self, component_name: Optional[str], component_type: Optional[Type], message: str) -> None:
14-
self.component_name = component_name
15-
self.component_type = component_type
16-
super().__init__(message)
17-
18-
@classmethod
19-
def from_exception(cls, component_name: str, component_type: Type, error: Exception) -> "PipelineRuntimeError":
20-
"""
21-
Create a PipelineRuntimeError from an exception.
22-
"""
23-
message = (
24-
f"The following component failed to run:\n"
25-
f"Component name: '{component_name}'\n"
26-
f"Component type: '{component_type.__name__}'\n"
27-
f"Error: {str(error)}"
28-
)
29-
return cls(component_name, component_type, message)
30-
31-
@classmethod
32-
def from_invalid_output(cls, component_name: str, component_type: Type, output: Any) -> "PipelineRuntimeError":
33-
"""
34-
Create a PipelineRuntimeError from an invalid output.
35-
"""
36-
message = (
37-
f"The following component returned an invalid output:\n"
38-
f"Component name: '{component_name}'\n"
39-
f"Component type: '{component_type.__name__}'\n"
40-
f"Expected a dictionary, but got {type(output).__name__} instead.\n"
41-
f"Check the component's output and ensure it is a valid dictionary."
42-
)
43-
return cls(component_name, component_type, message)
44-
45-
46-
class PipelineComponentsBlockedError(PipelineRuntimeError):
47-
def __init__(self) -> None:
48-
message = (
49-
"Cannot run pipeline - all components are blocked. "
50-
"This typically happens when:\n"
51-
"1. There is no valid entry point for the pipeline\n"
52-
"2. There is a circular dependency preventing the pipeline from running\n"
53-
"Check the connections between these components and ensure all required inputs are provided."
54-
)
55-
super().__init__(None, None, message)
56-
57-
58-
class PipelineConnectError(PipelineError):
59-
pass
60-
61-
62-
class PipelineValidationError(PipelineError):
63-
pass
64-
65-
66-
class PipelineDrawingError(PipelineError):
67-
pass
68-
69-
70-
class PipelineMaxComponentRuns(PipelineError):
71-
pass
72-
73-
74-
class PipelineUnmarshalError(PipelineError):
75-
pass
76-
77-
78-
class ComponentError(Exception):
79-
pass
80-
81-
82-
class ComponentDeserializationError(Exception):
83-
pass
84-
85-
86-
class DeserializationError(Exception):
87-
pass
88-
89-
90-
class SerializationError(Exception):
91-
pass
5+
from typing import Any, Dict, Optional
926

937

948
class PipelineBreakpointException(Exception):
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
from .pipeline import Pipeline
6+
7+
__all__ = ["Pipeline"]

0 commit comments

Comments
 (0)