fix(data): align filter() kwarg between Python stub and pybind#1511
Open
Ace3Z wants to merge 1 commit into
Open
fix(data): align filter() kwarg between Python stub and pybind#1511Ace3Z wants to merge 1 commit into
Ace3Z wants to merge 1 commit into
Conversation
12a1b86 to
e61bf98
Compare
The Python stub `DataPipelineBuilder.filter` declared `predicate` while
the C++ pybind binding used `py::arg("fn")`, so calling
`pipeline.filter(predicate=...)` (the documented form) raised
`TypeError: incompatible function arguments`.
Same bug class as facebookresearch#1103 and the fix that landed in facebookresearch#1510 for
`dynamic_bucket`. Rename the pybind keyword from `fn` to `predicate`
so the runtime matches the documented Python signature. No internal
callsite uses the keyword form, so this is source-compatible for all
existing callers.
Follow-up to facebookresearch#1510.
e61bf98 to
b1e1e2c
Compare
Author
|
Friendly ping. This is the sibling of #1510, the same one line kwarg fix but applied to filter(). @cirquit @cbalioglu a quick look when you get a chance would be great. |
Author
|
Friendly ping. @cbalioglu, would you have a moment to look at this? Tiny pybind/stub alignment fix. Happy to address any feedback. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up to #1510 for the same bug class.
The Python stub at
src/fairseq2/data/data_pipeline.py:275declaresdef filter(self, predicate: ...), but the pybind binding atnative/python/src/fairseq2n/bindings/data/data_pipeline.cc:516exposed the arg aspy::arg("fn"). So callingpipeline.filter(predicate=...)blows up:Renamed the pybind kwarg from
fntopredicateto match the documented Python signature. I grep'd every.filter(call acrosssrc/,tests/,examples/, andrecipes/: there are 17 callers, all of them pass the predicate positionally, none usefn=. So no internal breakage.Added a regression test in
tests/unit/data/data_pipeline/test_filter.pythat callsfilterwithpredicate=as a kwarg. Built fairseq2n from source on Linux + Python 3.12 + Torch 2.12 and ran the A/B cycle: test fails against the unpatched binding with the exactTypeErrorabove, passes against the patched one. The other two tests inTestFilterOpare unchanged and still pass.As promised in the description of #1510.