Skip to content

Commit 4830cb9

Browse files
committed
Remove remaining deprecation tools as unused.
1 parent 6c0f140 commit 4830cb9

File tree

5 files changed

+3
-168
lines changed

5 files changed

+3
-168
lines changed

src/libtorchaudio/shim_temporary.h

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/torchaudio/_internal/module_utils.py

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import importlib.util
22
import os
3-
import warnings
4-
from functools import partial, wraps
5-
from typing import Optional
3+
from functools import wraps
64

75

86
def eval_env(var, default):
@@ -60,99 +58,6 @@ def wrapped(*args, **kwargs):
6058
return decorator
6159

6260

63-
UNSUPPORTED = []
64-
65-
66-
def wrap_deprecated(func, name, direction: str, version: Optional[str] = None, remove: bool = False):
67-
@wraps(func)
68-
def wrapped(*args, **kwargs):
69-
message = f"{name} has been deprecated. {direction}"
70-
if remove:
71-
message += f' It will be removed from {"a future" if version is None else "the " + str(version)} release. '
72-
warnings.warn(message, stacklevel=2)
73-
return func(*args, **kwargs)
74-
75-
return wrapped
76-
77-
78-
def deprecated(direction: str, version: Optional[str] = None, remove: bool = False):
79-
"""Decorator to add deprecation message
80-
81-
Args:
82-
direction (str): Migration steps to be given to users.
83-
version (str or int): The version when the object will be removed
84-
remove (bool): If enabled, append future removal message.
85-
"""
86-
87-
def decorator(func):
88-
wrapped = wrap_deprecated(func, f"{func.__module__}.{func.__name__}", direction, version=version, remove=remove)
89-
90-
message = "This function has been deprecated. "
91-
if remove:
92-
message += f'It will be removed from {"future" if version is None else version} release. '
93-
94-
wrapped.__doc__ = f"""DEPRECATED
95-
96-
.. warning::
97-
98-
{message}
99-
{direction}
100-
101-
{func.__doc__}
102-
"""
103-
104-
return wrapped
105-
106-
return decorator
107-
108-
109-
DEPRECATION_MSG = (
110-
"This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. "
111-
"Please see https://github.com/pytorch/audio/issues/3902 for more information."
112-
)
113-
114-
IO_DEPRECATION_MSG = (
115-
"This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. "
116-
"The decoding and encoding capabilities of PyTorch for both audio"
117-
" and video are being consolidated into TorchCodec. "
118-
"Please see https://github.com/pytorch/audio/issues/3902 for more information."
119-
)
120-
121-
dropping_support = deprecated(DEPRECATION_MSG, version="2.9", remove=True)
122-
123-
124-
def dropping_class_support(c, msg=DEPRECATION_MSG):
125-
c.__init__ = wrap_deprecated(c.__init__, f"{c.__module__}.{c.__name__}", msg, version="2.9", remove=True)
126-
c.__doc__ = f"""DEPRECATED
127-
128-
.. warning::
129-
130-
This class is deprecated from version 2.8. It will be removed in the 2.9 release.
131-
{msg}
132-
{c.__doc__}
133-
"""
134-
135-
UNSUPPORTED.append(c)
136-
return c
137-
138-
139-
def dropping_const_support(c, msg=DEPRECATION_MSG, name=None):
140-
c.__doc__ = f"""[DEPRECATED]
141-
142-
.. warning::
143-
144-
This object is deprecated deprecated from version 2.8. It will be removed in the 2.9 release.
145-
{msg}
146-
{c.__doc__}
147-
"""
148-
return c
149-
150-
151-
dropping_class_io_support = partial(dropping_class_support, msg=IO_DEPRECATION_MSG)
152-
153-
dropping_io_support = deprecated(IO_DEPRECATION_MSG, version="2.9", remove=True)
154-
155-
15661
def fail_with_message(message):
15762
"""Generate decorator to give users message about missing TorchAudio extension."""
15863

src/torchaudio/models/decoder/__init__.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import inspect
2-
3-
from torchaudio._internal.module_utils import dropping_class_support, dropping_support
4-
51
_CTC_DECODERS = [
62
"CTCHypothesis",
73
"CTCDecoder",
@@ -37,21 +33,7 @@ def __getattr__(name: str):
3733
"To use CUCTC decoder, please set BUILD_CUDA_CTC_DECODER=1 when building from source."
3834
) from err
3935

40-
# TODO: when all unsupported classes are removed, replace the
41-
# following if-else block with
42-
# item = getattr(_cuda_ctc_decoder, name)
43-
orig_item = getattr(_cuda_ctc_decoder, name)
44-
if inspect.isclass(orig_item) or (
45-
# workaround a failure to detect type instances
46-
# after sphinx autodoc mocking, required for
47-
# building docs
48-
getattr(orig_item, "__sphinx_mock__", False)
49-
and inspect.isclass(orig_item.__class__)
50-
):
51-
item = dropping_class_support(orig_item)
52-
else:
53-
item = dropping_support(orig_item)
54-
36+
item = getattr(_cuda_ctc_decoder, name)
5537
globals()[name] = item
5638
return item
5739
raise AttributeError(f"module {__name__} has no attribute {name}")

src/torchaudio/transforms/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from torchaudio._internal.module_utils import dropping_class_support
2-
31
from ._multi_channel import MVDR, PSD, RTFMVDR, SoudenMVDR
42
from ._transforms import (
53
AddNoise,
@@ -23,7 +21,7 @@
2321
PitchShift,
2422
Preemphasis,
2523
Resample,
26-
RNNTLoss as _RNNTLoss,
24+
RNNTLoss,
2725
SlidingWindowCmn,
2826
SpecAugment,
2927
SpectralCentroid,
@@ -36,8 +34,6 @@
3634
Vol,
3735
)
3836

39-
RNNTLoss = dropping_class_support(_RNNTLoss)
40-
4137
__all__ = [
4238
"AddNoise",
4339
"AmplitudeToDB",

test/torchaudio_unittest/deprecation_test.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)