haystack
                                
                                 haystack copied to clipboard
                                
                                    haystack copied to clipboard
                            
                            
                            
                        Lazy Run/Evaluation of components based on downstream necessity
Came up in #6836
Wondering if there is a way to setup a component to only run if there is a downstream component needing its output.
E.g. Possible usage: the FilterRetriever (which simply runs a preset filter on a document-store) is in one of many optional branches. And we would only want to run it if the branch is followed (e.g. for a certain type of query). I guess this can be generalized to any "inputless" component.
One such setup could be:
Here we'd want the FilterRetriever to run only when necessary (LookupReader needs its output).
Describe alternatives you've considered
- Could set up the component (here FilterRetriever) to take some "trigger" input.
- Or just ignore components being run unnecessarily.
@bglearning can you try to run this code with the main branch? The new run algorithm should behave like you expect.
@masci Seems like it still runs the unnecessary component (here FilterRetriever for the SemanticReader branch).
afaict, components with no inputs are immediately added into to_run in the run algorithm.