Skip to content

chore: standardise deprecations using the warn_deprecated helper - #2030

Closed
lorinczszabolcs wants to merge 2 commits into
lightly-ai:masterfrom
lorinczszabolcs:standardise-deprecations
Closed

chore: standardise deprecations using the warn_deprecated helper#2030
lorinczszabolcs wants to merge 2 commits into
lightly-ai:masterfrom
lorinczszabolcs:standardise-deprecations

Conversation

@lorinczszabolcs

Copy link
Copy Markdown
Contributor

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 a FutureWarning and 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 own weight_norm and _pytree warnings are allowlisted because they are not ours to fix.

Questions:

  • The collate deprecation is allowlisted because the train CLI still builds a collate function internally (lightly/cli/train_cli.py), which trips the guard. With the guard on, lightly-train now shows this FutureWarning to 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?
  • The removal version is 1.7.0 to match the decoders deprecated in Deprecate mae pixio decoder timm #2006.

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.
@lorinczszabolcs

Copy link
Copy Markdown
Contributor Author

Closing this. I opened it before realizing the same thing is being worked on in #2021 and #1939

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardise deprecations on a single helper

1 participant