-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move essential backend implementations to _backend
Move the actual I/O implementation to _backend submodule so that the new _backend does not depend on the legacy backend, and the existing backend submodule contains only what's related to legacy backend utilities. The legacy implementation depends on the new one.
- Loading branch information
Showing
12 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,42 @@ | ||
# NOTE: | ||
# The entire `torchaudio.backend` module is deprecated. | ||
# New things should be added to `torchaudio._backend`. | ||
# Only things related to backward compatibility should be placed here. | ||
|
||
from .utils import _init_backend, get_audio_backend, list_audio_backends, set_audio_backend | ||
|
||
|
||
__all__ = ["_init_backend", "get_audio_backend", "list_audio_backends", "set_audio_backend"] | ||
|
||
|
||
def __getattr__(name: str): | ||
import warnings | ||
|
||
if name == "sox_io_backend": | ||
warnings.warn( | ||
"Torchaudio's I/O functions now support par-call bakcend dispatch. " | ||
"Importing backend implementation directly is no longer guaranteed to work. " | ||
"Please use `backend` keyword with load/save/info function, instead of " | ||
"calling the udnerlying implementation directly.", | ||
stacklevel=2, | ||
) | ||
from . import sox_io_backend | ||
|
||
return sox_io_backend | ||
if name == "soundfile_backend": | ||
warnings.warn( | ||
"Torchaudio's I/O functions now support par-call bakcend dispatch. " | ||
"Importing backend implementation directly is no longer guaranteed to work. " | ||
"Please use `backend` keyword with load/save/info functions, instead of " | ||
"calling the udnerlying implementation directly.", | ||
stacklevel=2, | ||
) | ||
from torchaudio._backend import soundfile_backend | ||
|
||
return soundfile_backend | ||
|
||
if name == "common": | ||
from . import _common | ||
|
||
return _common | ||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def __getattr__(name: str): | ||
import warnings | ||
|
||
if name == "AudioMetaData": | ||
warnings.warn( | ||
"`torchaudio.backend.common.AudioMetaData` has been moved to " | ||
"`torchaudio.AudioMetaData`. Please update the import path.", | ||
stacklevel=2, | ||
) | ||
from torchaudio._backend.common import AudioMetaData | ||
|
||
return AudioMetaData | ||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
This file contains 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
This file contains 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