Fix LightningCLI optional callback handling in subclass mode#21527
Open
KAVYANSHTYAGI wants to merge 10 commits intoLightning-AI:masterfrom
Open
Fix LightningCLI optional callback handling in subclass mode#21527KAVYANSHTYAGI wants to merge 10 commits intoLightning-AI:masterfrom
KAVYANSHTYAGI wants to merge 10 commits intoLightning-AI:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #21527 +/- ##
=========================================
- Coverage 87% 79% -8%
=========================================
Files 270 267 -3
Lines 24069 24018 -51
=========================================
- Hits 20868 18962 -1906
- Misses 3201 5056 +1855 |
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.
When add_lightning_class_args(..., subclass_mode=True, required=False) is used for callbacks and no CLI argument is provided, the resolved value is None.
Previously, LightningCLI.instantiate_trainer unconditionally appended these values to the Trainer callbacks list, allowing None entries to silently propagate.
This PR filters out None callback entries before passing them to the Trainer, preserving the invariant that Trainer.callbacks contains only Callback instances.
A regression test is added to cover optional subclass-mode callback arguments.