You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifnotgetattr(self.body, "output_size", None)():
raiseValueError(
"Can't infer output-size of the body, please provide ""a `Block` with a output-size. You can wrap any torch.Module in a Block."
)
When self.body does not have an output_size attribute, getattr(..., None) returns None, and the trailing () then evaluates None(), which raises TypeError: 'NoneType' object is not callable.
The original lambda: None sentinel was callable and returned a falsy value, so the intended raise ValueError(...) path below was actually reached. The current code path short-circuits with the wrong exception type, making the error message unactionable.
This is not caught by tests because all fixtures provide bodies with output_size.
Steps/Code to reproduce bug
classBody:
passbody=Body()
getattr(body, "output_size", None)()
# TypeError: 'NoneType' object is not callable
getattr(body, "output_size", lambda: None)()
# None (falsy, falls through to `raise ValueError(...)` in Head.build)
Expected behavior
When the body lacks output_size, Head.build should raise the original ValueError("Can't infer output-size of the body ...") so the user gets a clear, actionable message.
Environment details
Transformers4Rec: main @ 8bf122f5 (regression introduced by PR Sec pic fix #802 / commit ab7207cf)
Bug description
PR #802 (commit
ab7207cf, "Sec pic fix") changed the default sentinel intransformers4rec/torch/model/base.pyfromlambda: NonetoNone:Transformers4Rec/transformers4rec/torch/model/base.py
Line 288 in 8bf122f
When
self.bodydoes not have anoutput_sizeattribute,getattr(..., None)returnsNone, and the trailing()then evaluatesNone(), which raisesTypeError: 'NoneType' object is not callable.The original
lambda: Nonesentinel was callable and returned a falsy value, so the intendedraise ValueError(...)path below was actually reached. The current code path short-circuits with the wrong exception type, making the error message unactionable.This is not caught by tests because all fixtures provide bodies with
output_size.Steps/Code to reproduce bug
Versus the pre-#802 behavior:
Expected behavior
When the body lacks
output_size,Head.buildshould raise the originalValueError("Can't infer output-size of the body ...")so the user gets a clear, actionable message.Environment details
main@8bf122f5(regression introduced by PR Sec pic fix #802 / commitab7207cf)Additional context
Two equivalent minimal fixes:
Option A — restore the callable sentinel:
Option B — explicit two-step check (slightly more readable):
Option A preserves behavior byte-for-byte. Happy to send a PR.