fix: SuperComponent input filter must use identity, not equality
Proposed Changes:
SuperComponent.run and SuperComponent.run_async filtered out the internal _delegate_default sentinel with value != _delegate_default. That calls __ne__ on every user-provided input, which for numpy arrays, pandas DataFrames/Series, and torch tensors returns an element-wise array, and the dict-comprehension's boolean context then raises ValueError: The truth value of ... is ambiguous. So passing any array-shaped input (a routine ML pipeline thing) failed before the wrapped pipeline ever ran.
Switched both call sites to is not _delegate_default. That's an identity check on a sentinel class — what the filter actually meant, and it never touches __ne__ on user values.
How did you test it?
- Added two unit tests in
TestSuperComponentDelegateDefaultFilteringcovering the sync (run) and async (run_async) paths with a realnumpy.ndarrayinput. hatch run test:unit test/core/super_component/, all 29 tests pass (27 pre-existing + 2 new).hatch run test:unit test/core/, 1587 passed, no regressions.hatch run test:types haystack/core/super_component/super_component.py: clean.hatch run fmt-check: clean.
Notes for the reviewer
- Two-line behavioural change, repeated in
run(line 122) andrun_async(line 150). I kept a one-line# is not, not !=comment above each so the next reader doesn't "simplify" it back. - Semantic equivalence for ordinary values:
_delegate_defaultis a class object with no__eq__override, so for any value that doesn't overload__ne__,!=andis notproduce the same result. Behaviour changes only for (a) array-like values that overload__ne__to return non-scalar (the fix), and (b) the pathological case of a user class whose__eq__returnsTruefor everything (previously silently dropped, now correctly kept, strict improvement). - Release note added under
releasenotes/notes/.
Checklist
- I have read the contributors guidelines and the code of conduct.
- I have updated the related issue with new insights and changes.
- I have added unit tests and updated the docstrings.
- I've used one of the conventional commit types for my PR title:
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes. - I have documented my code.
- I have added a release note file, following the contributors guidelines.
- I have run pre-commit hooks and fixed any issue.
@Aarkin7 is attempting to deploy a commit to the deepset Team on Vercel.
A member of the Team first needs to authorize it.
@bogdankostic for some additional context we did run into a problem like this before in our Pipeline class here https://github.com/deepset-ai/haystack/pull/8873
@bogdankostic I can take over the review for this
Hey @Aarkin7 soft ping to address this comment https://github.com/deepset-ai/haystack/pull/11624#discussion_r3433784366
Hey @Aarkin7 do you have time to work on this in the near future?
Hi @sjrl I'll look into it
Coverage report
This report was generated by python-coverage-comment-action
Click to see where and how coverage changed
File Statements Missing Coverage Coverage
(new stmts)Lines missing
haystack/core/super_component
super_component.py
149
Project Total
Hi @sjrl , Thanks! Moved numpy to a normal top-level import and removed the importorskip from both tests.