Skip to content

Commit

Permalink
add deprecation warning for deprecated modules (#1277)
Browse files Browse the repository at this point in the history
* add deprecation warning for deprecated modules

* fix deprecation warning

* fix formatting

* remove unused var
  • Loading branch information
andrewkho authored Jun 14, 2024
1 parent 2ee03ae commit 958eeb0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions torchdata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,23 @@ def __getattr__(name):
return globals()[name]
else:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


_warning_shown = False


def deprecation_warning():
global _warning_shown
if not _warning_shown:
_warning_shown = True
import warnings

warnings.warn(
"\n################################################################################\n"
"WARNING!\n"
"The 'datapipes', 'dataloader2' modules are deprecated and will be removed in a\n"
"future torchdata release! Please see https://github.com/pytorch/data/issues/1196\n"
"to learn more and leave feedback.\n"
"################################################################################\n",
stacklevel=2,
)
5 changes: 5 additions & 0 deletions torchdata/dataloader2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
]

assert __all__ == sorted(__all__)


from torchdata import deprecation_warning

deprecation_warning()
5 changes: 5 additions & 0 deletions torchdata/datapipes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
from . import iter, map, utils

__all__ = ["DataChunk", "functional_datapipe", "iter", "map", "utils"]


from torchdata import deprecation_warning

deprecation_warning()

0 comments on commit 958eeb0

Please sign in to comment.