component implementation #6799
-
Hi, I'm wondering why |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@silvanocerza please help |
Beta Was this translation helpful? Give feedback.
-
We didn't want to use inheritance too much in Haystack 2.x to avoid creating a huge inheritance tree like we had in Haystack 1.x. There are some benefits that make the code easier to understand too.
This makes it clear right away that is something related to the Haystack logic of the Component and/or Pipeline. Using inheritance you'd have to set that either in the class definition or in Same thing can be said for the Also the code to create a Component looks cleaner and much more elegant in my opinion. In any case we debated quite a bit on the benefit of one or the other and decided to settle on this approach. At certain points we almost switched to inheritance. Just to show how it wasn't a decision made on overwhelming benefits from one side. Inheritance still has some benefits. |
Beta Was this translation helpful? Give feedback.
We didn't want to use inheritance too much in Haystack 2.x to avoid creating a huge inheritance tree like we had in Haystack 1.x.
There are some benefits that make the code easier to understand too.
As of now
@component
doesn't take any arguments but in the future it will, so we write something like this.This makes it clear right away that is something related to the Haystack logic of the Component and/or Pipeline. Using inheritance you'd have to set that either in the class definition or in
__init__
, that might not made it clear to maintainers what is it about.Same thing can be said for the
@component.input_types()
decorator andcompo…