-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add pipeline run with kwargs to Haystack 2.x #6266
Conversation
I'm hesitant to "pollute" the keyword args for the # current approach
result = pipeline.run(data={"hello": {"word": "world"}})
# new simplified input resolution approach
result = pipeline.run(data={"word": "world"}) |
One option we also have, which I'm not sure how smart is, is to leave the overloads along with bare kwargs run, while documenting and promoting data parameter run only. |
71ff449
to
33edfe5
Compare
Increasing the visibility from Draft to Open, although this PR is not ready yet. I would love to get your general feedback one more time before I add more unit tests. See a single unit test to understand how we now support three pipeline run invocation variants:
Let's have a discussion about what's best going forward. |
I personally prefer the kwargs approach, like: pipeline.run(hello="world") indeed that would "pollute" the run method kwargs, but there is always the option of setting other parameters as attributes, like: pipeline.max_loops = 10
pipeline.debug = True
pipeline.run(hello="world") Not the most elegant, but could work I believe. We may even keep the "old" dict-based run method as a private method, such as: pipeline._run(data={"greet": {"hello": "world"}}, max_loops=10) to be used in case of need. |
Please keep in mind reversibility and uncertainty here: at the time being we are not sure we won't need to pass additional keyword arguments to On the other side, by simplifying the |
I think the code can be much simpler than this if we keep the |
No problem @masci , I'll simplify and add more unit tests! |
This should be it, more or less. If someone can figure out how to create a unit test to cause some unexpected or non-logical result - please do. |
Why:
The current implementation of Haystack 2.x pipelines requires users to explicitly map input data to specific components, which can be cumbersome and error-prone, especially as the complexity of the pipeline grows.
What:
We've streamlined the process of feeding inputs into the pipeline by allowing users to pass kwargs directly. The pipeline can now intelligently resolve which components can utilize the provided inputs, simplifying the interface and reducing the likelihood of user errors.
How can it be used:
With this enhancement, running a pipeline becomes more intuitive. Users can provide the inputs without specifying the components they correspond to:
How did you test it:
This is a work in progress as we await a release of the latest canals with supporting methods for component input that this PR relies on. The unit tests will be in
test/preview/test_pipeline.py
Notes for reviewer:
This is a draft for now so we can discuss the approach early. We are still awaiting the new release of canals.
DO NOT INTEGRATE