Create VariadicGreedy
input type and remove is_greedy
argument from component
decorator
#7871
Labels
2.x
Related to Haystack v2.0
P2
Medium priority, add to the next sprint if no P1 available
topic:core
When creating a new Component I must decorate it with a
@component
decorator.As of now that decorator takes a single
bool
argumentis_greedy
as defined here.That
is_greedy
argument in turn sets temporarily the__haystack_is_greedy__
internal class dunder field here. The comment says that is done temporarily but, as we see in the following paragraph, is actually wrong. When we started implementing that we assumed it would be temporary because "greediness" of a Component also depends on the type of inputs the it takes, and at that point of the execution we can't yet know reliably know the input types of the Component.Then here, in the
ComponentMeta
metaclass, where we can actually reliably check the actual real type of inputs the Component takes we emit a warning letting the user know if they setis_greedy
toTrue
and there's no input withVariadic
type.This is necessary because Components that have
Variadic
input and haveis_greedy
asTrue
behave in a different way from Components that haveVariadic
inpot and haveis_greedy
asFalse
when callingPipeline.run()
. To be precise here we check if a Component hasVariadic
as input type and also has setis_greedy
toTrue
.The core difference between a Component that have
Variadic
input and haveis_greedy
asTrue
and one that hasis_greedy
asFalse
is thatPipeline.run()
will wait as long as possible before trying to execute the Component that hasis_greedy
asFalse
. While the Component withis_greedy
asTrue
will be added to the list of Components that are ready to run as soon as it receives the first input from any sender Component it's connected with.As this is error prone and "greediness" of a Component is associated to its input types we should actually remove the
is_greedy
argument. And instead of relying on@component
decorator arguments to set this information we should create aVariadicGreedy
type, much like we have aVariadic
type.This will make more evident which Component actually is "greedy" and clearly show that "greediness" is associated with
Variadic
input types.The text was updated successfully, but these errors were encountered: