Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add removeable warnings indicating this is the last release #2248

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions torchtext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@

from torch.hub import _get_torch_home

_WARN = True
_TORCHTEXT_DEPRECATION_MSG = (
"\n/!\ IMPORTANT WARNING ABOUT TORCHTEXT STATUS /!\ \n"
"Torchtext is deprecated and the last released version will be 0.18 (this one). "
"You can silence this warning by calling the following at the beginnign of your scripts: "
"`import torchtext; torchtext.disable_torchtext_deprecation_warning()`"
)

def disable_torchtext_deprecation_warning():
global _WARN
_WARN = False

# the following import has to happen first in order to load the torchtext C++ library
from torchtext import _extension # noqa: F401

_TEXT_BUCKET = "https://download.pytorch.org/models/text/"

_CACHE_DIR = os.path.expanduser(os.path.join(_get_torch_home(), "text"))

from . import data, datasets, prototype, functional, models, nn, transforms, utils, vocab, experimental

try:
from .version import __version__, git_version # noqa: F401
except ImportError:
Expand Down
6 changes: 6 additions & 0 deletions torchtext/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)


from .functional import (
custom_replace,
filter_wikipedia_xml,
Expand Down
6 changes: 6 additions & 0 deletions torchtext/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)


import importlib

from .ag_news import AG_NEWS
Expand Down
4 changes: 4 additions & 0 deletions torchtext/experimental/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)
5 changes: 5 additions & 0 deletions torchtext/functional.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)

from typing import Any, List, Optional

import torch
Expand Down
5 changes: 5 additions & 0 deletions torchtext/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)

from .roberta import * # noqa: F401, F403
from .t5 import * # noqa: F401, F403
5 changes: 5 additions & 0 deletions torchtext/nn/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)

from .modules import * # noqa: F401,F403
5 changes: 5 additions & 0 deletions torchtext/prototype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)

from . import transforms

__all__ = ["transforms"]
6 changes: 6 additions & 0 deletions torchtext/transforms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)


import json
import re
from copy import deepcopy
Expand Down
5 changes: 5 additions & 0 deletions torchtext/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)

import gzip
import hashlib
import logging
Expand Down
5 changes: 5 additions & 0 deletions torchtext/vocab/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import warnings
import torchtext
if torchtext._WARN:
warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG)

from .vectors import CharNGram, FastText, GloVe, pretrained_aliases, Vectors
from .vocab import Vocab
from .vocab_factory import build_vocab_from_iterator, vocab
Expand Down
Loading