Normalize lists argument in MerlinDataLoader._augment_schema#818
Open
shaun0927 wants to merge 1 commit into
Open
Normalize lists argument in MerlinDataLoader._augment_schema#818shaun0927 wants to merge 1 commit into
lists argument in MerlinDataLoader._augment_schema#818shaun0927 wants to merge 1 commit into
Conversation
cats/conts/labels are normalized to [] when None, but lists was not. The subsequent 'conts + cats + labels + lists' raises TypeError: can only concatenate list (not "NoneType") to list for any caller that omits lists=, which is the common case for datasets without list-typed features. Fixes NVIDIA-Merlin#812
Author
|
FYI — I have read |
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.
Goals ⚽
Stop
MerlinDataLoader._augment_schemafrom raisingTypeErrorwhen the caller omitslists=(the common case for datasets without list-typed features).Fixes #812.
Implementation Details 🚧
transformers4rec/torch/utils/data_utils.pynormalizescats,conts, andlabelsto empty lists when they default toNone, but the normalization forlistswas missing:Any caller that does not pass
lists=(or passeslists=Noneexplicitly) hitsTypeError: can only concatenate list (not "NoneType") to listat theselect_by_nameline. The laterfor col in lists:loop would also raiseTypeError: 'NoneType' object is not iterable.Minimal fix — add the symmetric
lists = lists or []alongside the other three:cats = cats or [] conts = conts or [] labels = labels or [] + lists = lists or [] schema = schema.select_by_name(conts + cats + labels + lists)Testing Details 🔍
Pre-fix repro (extracted from the source, no install needed):
With the patch, the same call succeeds.
No unit test is added —
_augment_schemais currently exercised indirectly by everyMerlinDataLoaderconstruction in the test suite that supplieslists=[...]. I am happy to add a direct test forlists=Noneif reviewers would prefer.