Skip to content

Centralize deprecation version markers in DeprecatedSince - #3444

Merged
deruyter92 merged 7 commits into
jaap/prepare_tf_deprecationfrom
jaap/deprecation-versions-constants
Aug 20, 2026
Merged

deruyter92 merged 7 commits into
jaap/prepare_tf_deprecationfrom
jaap/deprecation-versions-constants

Conversation

@deruyter92

@deruyter92 deruyter92 commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation
PR #3332 introduced a deprecation system for deprecated functions and parameter aliasing. Although this significantly centralized things, the actual decorators markering the deprecations are now spread throughout the codebase and the since parameter is redefined on every occurrence, making mistakes easy.

This PR centralizes the administration in a single DeprecationRound enum, that serves as the single source of truth, and references the specific deprecation rounds and corresponding pull requests.

Example usage

  1. Register a new deprecation round in the DeprecationRound enum
# ‎deeplabcut/core/deprecation.py

class DeprecationRound(Enum):
    """Collection of all deprecation rounds used in the deprecation markers - single source of truth."""
    ...
    
    PATHLIB_MIGRATION = DeprecationRoundInfo(
        since="3.0.1",
        pull_request=3421,
        summary="Migrate str path handling to pathlib.Path, including grab_files_in_folder",
    )
  1. Mark the deprecated function, specifying deprecation_round
# deprecated function 
from deeplabcut.core.deprecation import deprecated, DeprecationRound

@deprecated(replacement="deeplabcut.collect_video_paths", deprecation_round=DeprecationRound.PATHLIB_MIGRATION)
def grab_files_in_folder(folder, ext="", relative=True):
....

Changes

  • Add and wire new DeprecationRound enum and DeprecationRoundInfo schema, listing existing deprecation rounds
  • Add tests for the new deprecation logic

@C-Achard C-Achard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, note that the suggestions for additional dataclasses only matter if we want some sort of fancy automated ingestion, for maintaining it is likely redundant.

Feel free to cherry pick what you like and ignore the rest!

Comment thread deeplabcut/core/deprecation.py Resolved
Comment thread deeplabcut/core/deprecation.py Resolved
Comment thread deeplabcut/core/deprecation.py Resolved
Comment thread deeplabcut/core/deprecation.py Resolved
@C-Achard C-Achard added enhancement New feature or request documentation documentation updates/comments labels Aug 13, 2026
@C-Achard C-Achard added this to the v3.0.2 milestone Aug 13, 2026
@deruyter92
deruyter92 force-pushed the jaap/deprecation-versions-constants branch from 4e6f30b to 3c819f4 Compare August 13, 2026 14:17
@deruyter92

Copy link
Copy Markdown
Collaborator Author

@C-Achard Applied all your suggestions, thanks for the review.

Note, I've rebased the PR to make it better reviewable (and fixed the commit messages).

Comment thread deeplabcut/core/deprecation.py Resolved
@deruyter92
deruyter92 marked this pull request as ready for review August 19, 2026 09:08
@deruyter92
deruyter92 force-pushed the jaap/deprecation-versions-constants branch from b8a1119 to 335b8d5 Compare August 19, 2026 16:07
Base automatically changed from jaap/remove-rst-files to jaap/prepare_tf_deprecation August 20, 2026 14:29
add test keeping version literals out of deprecation markers
Walks the shipped package and fails on any since= or removed_in= literal, so
DeprecatedSince stays the single source of truth. deprecation.py is exempt:
its docstrings illustrate the API with literal versions.
Also checks that every constant parses as a version.
Every @deprecated and @renamed_parameter marker spelled its version inline, so
a round of deprecations could only be retargeted by grepping for version
strings across the codebase. That is how the 3.1 -> 3.0.1 sweep in #3422 missed
analyze_time_lapse_frames, and it makes it easy to move an unrelated API while
retargeting one round.
DeprecatedSince now holds one constant per round, named after the migration
rather than its version so a retargeted round keeps its name, and annotated
with the PR that introduced it. All 67 markers reference it.
Fix incorrect deprecation description PRETRAINED_PROJECT_MIGRATION, which listed the wrong version for `since`. Merge into more descriptive name, relating to the TF deprecation (which is the main motivation).
…SING

A more descriptive name was needed to avoid ambiguity with next follow-up parameter consistency migrations. This refers to the initial PR that introduced the aliasing system and DeprecationWarnings
@deruyter92
deruyter92 force-pushed the jaap/deprecation-versions-constants branch from f3489a8 to c157f0a Compare August 20, 2026 14:53
@deruyter92
deruyter92 merged commit 53df465 into jaap/prepare_tf_deprecation Aug 20, 2026
1 check passed
@deruyter92
deruyter92 deleted the jaap/deprecation-versions-constants branch August 20, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation documentation updates/comments enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants