chore: standardise deprecations using the warn_deprecated helper - #2030
Closed
lorinczszabolcs wants to merge 2 commits into
Closed
chore: standardise deprecations using the warn_deprecated helper#2030lorinczszabolcs wants to merge 2 commits into
lorinczszabolcs wants to merge 2 commits into
Conversation
Route the high-level model blocks (BarlowTwins, BYOL, MoCo, NNCLR, SimCLR, SimSiam), the collate-function API, and the active-learning entrypoint off ad-hoc warnings.warn calls onto warn_deprecated (added in lightly-ai#2006). They now emit a FutureWarning shown by default instead of a DeprecationWarning/bare Warning, and reference a real removal version (1.7.0) in place of the stale 1.3.0/1.4.0 strings. Add per-class deprecation tests and refresh the stale models package docstring. Refs lightly-ai#2019.
Add a filterwarnings guard so a deprecated API is never called silently in tests, the gap that let the deprecated decoders go unnoticed before lightly-ai#2006. Tests that exercise a now-migrated deprecation on purpose (the high-level model wrappers and the active-learning selection config) opt out with @pytest.mark.filterwarnings("ignore::FutureWarning"). FutureWarnings lightly cannot fix here are allowlisted: the collate-function API (still built internally by legacy CLI/core paths) and torch's own weight_norm/_pytree deprecations surfaced on newer torch. Refs lightly-ai#2019.
Contributor
Author
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.
Closes #2019. Follows up on #2006, which added
warn_deprecated.The high-level model classes (BarlowTwins, BYOL, MoCo, NNCLR, SimCLR, SimSiam), the collate functions, and the active-learning entry point now warn through
warn_deprecated. Each raises aFutureWarningand names 1.7.0 as the removal version, replacing the stale 1.3.0 and 1.4.0 strings. Each migrated symbol has a deprecation test.The pytest configuration sets
filterwarnings = ["error::FutureWarning", ...], so a deprecated API used in the tests fails the suite. Tests that use one on purpose opt out with a filter mark. Torch's ownweight_normand_pytreewarnings are allowlisted because they are not ours to fix.Questions:
lightly/cli/train_cli.py), which trips the guard. With the guard on,lightly-trainnow shows thisFutureWarningto users at runtime. Do you want to keep the allowlist and migrate the CLI to transforms in a follow-up, or handle it differently in this PR?