Skip to content

Commit e1e969d

Browse files
committed
Revert "Add Torchdata as a requirement and remove conditional imports of Torchdata (#1961) (#1962)"
This reverts commit 771b5a2.
1 parent a075bcc commit e1e969d

34 files changed

+151
-88
lines changed

packaging/torchtext/meta.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ requirements:
2323
- python
2424
- requests
2525
- tqdm
26-
- torchdata
2726
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
2827

2928
build:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def run(self):
100100
description="Text utilities and datasets for PyTorch",
101101
long_description=read("README.rst"),
102102
license="BSD",
103-
install_requires=["tqdm", "requests", pytorch_package_dep, "numpy", "torchdata"],
103+
install_requires=["tqdm", "requests", pytorch_package_dep, "numpy"],
104104
python_requires=">=3.7",
105105
classifiers=[
106106
"Programming Language :: Python :: 3.7",

torchtext/_download_hooks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
# This is to allow monkey-patching in fbcode
66
from torch.hub import load_state_dict_from_url # noqa
7-
from torchdata.datapipes.iter import HttpReader, GDriveReader # noqa F401
7+
from torchtext._internal.module_utils import is_module_available
88
from tqdm import tqdm
99

10+
if is_module_available("torchdata"):
11+
from torchdata.datapipes.iter import HttpReader, GDriveReader # noqa F401
12+
1013

1114
def _stream_response(r, chunk_size=16 * 1024):
1215
total_size = int(r.headers.get("Content-length", 0))

torchtext/datasets/ag_news.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
from functools import partial
33
from typing import Union, Tuple
44

5-
from torchdata.datapipes.iter import FileOpener, IterableWrapper
6-
from torchtext._download_hooks import HttpReader
75
from torchtext._internal.module_utils import is_module_available
86
from torchtext.data.datasets_utils import (
97
_wrap_split_argument,
108
_create_dataset_directory,
119
)
1210

11+
if is_module_available("torchdata"):
12+
from torchdata.datapipes.iter import FileOpener, IterableWrapper
13+
from torchtext._download_hooks import HttpReader
14+
1315
URL = {
1416
"train": "https://raw.githubusercontent.com/mhjabreel/CharCnn_Keras/master/data/ag_news_csv/train.csv",
1517
"test": "https://raw.githubusercontent.com/mhjabreel/CharCnn_Keras/master/data/ag_news_csv/test.csv",

torchtext/datasets/amazonreviewfull.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
from functools import partial
33
from typing import Union, Tuple
44

5-
from torchdata.datapipes.iter import FileOpener, IterableWrapper
6-
from torchtext._download_hooks import GDriveReader
75
from torchtext._internal.module_utils import is_module_available
86
from torchtext.data.datasets_utils import (
97
_wrap_split_argument,
108
_create_dataset_directory,
119
)
1210

11+
if is_module_available("torchdata"):
12+
from torchdata.datapipes.iter import FileOpener, IterableWrapper
13+
from torchtext._download_hooks import GDriveReader
14+
1315
URL = "https://drive.google.com/uc?export=download&id=0Bz8a_Dbh9QhbZVhsUnRWRDhETzA"
1416

1517
MD5 = "57d28bd5d930e772930baddf36641c7c"

torchtext/datasets/amazonreviewpolarity.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
from functools import partial
33
from typing import Union, Tuple
44

5-
from torchdata.datapipes.iter import FileOpener, IterableWrapper
6-
from torchtext._download_hooks import GDriveReader
75
from torchtext._internal.module_utils import is_module_available
86
from torchtext.data.datasets_utils import (
97
_wrap_split_argument,
108
_create_dataset_directory,
119
)
1210

11+
if is_module_available("torchdata"):
12+
from torchdata.datapipes.iter import FileOpener, IterableWrapper
13+
from torchtext._download_hooks import GDriveReader
14+
1315
URL = "https://drive.google.com/uc?export=download&id=0Bz8a_Dbh9QhbaW12WVVZS2drcnM"
1416

1517
MD5 = "fe39f8b653cada45afd5792e0f0e8f9b"

torchtext/datasets/cc100.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import os.path
22
from functools import partial
33

4-
from torchdata.datapipes.iter import FileOpener, IterableWrapper
5-
from torchtext._download_hooks import HttpReader
4+
from torchtext._internal.module_utils import is_module_available
65
from torchtext.data.datasets_utils import (
76
_create_dataset_directory,
87
)
98

9+
if is_module_available("torchdata"):
10+
from torchdata.datapipes.iter import FileOpener, IterableWrapper
11+
from torchtext._download_hooks import HttpReader
12+
1013
URL = "http://data.statmt.org/cc-100/%s.txt.xz"
1114

1215
VALID_CODES = {

torchtext/datasets/cnndm.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
from functools import partial
44
from typing import Union, Set, Tuple
55

6-
from torchdata.datapipes.iter import (
7-
FileOpener,
8-
IterableWrapper,
9-
OnlineReader,
10-
GDriveReader,
11-
)
126
from torchtext._internal.module_utils import is_module_available
137
from torchtext.data.datasets_utils import (
148
_wrap_split_argument,
159
_create_dataset_directory,
1610
)
1711

12+
if is_module_available("torchdata"):
13+
from torchdata.datapipes.iter import (
14+
FileOpener,
15+
IterableWrapper,
16+
OnlineReader,
17+
GDriveReader,
18+
)
19+
1820
DATASET_NAME = "CNNDM"
1921

2022
SPLIT_LIST = {

torchtext/datasets/cola.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
from functools import partial
44
from typing import Union, Tuple
55

6-
from torchdata.datapipes.iter import FileOpener, IterableWrapper
7-
from torchtext._download_hooks import HttpReader
86
from torchtext._internal.module_utils import is_module_available
97
from torchtext.data.datasets_utils import _create_dataset_directory, _wrap_split_argument
108

9+
if is_module_available("torchdata"):
10+
from torchdata.datapipes.iter import FileOpener, IterableWrapper
11+
from torchtext._download_hooks import HttpReader
12+
1113
URL = "https://nyu-mll.github.io/CoLA/cola_public_1.1.zip"
1214

1315
MD5 = "9f6d88c3558ec424cd9d66ea03589aba"

torchtext/datasets/conll2000chunking.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
from functools import partial
33
from typing import Union, Tuple
44

5-
from torchdata.datapipes.iter import FileOpener, IterableWrapper
6-
from torchtext._download_hooks import HttpReader
75
from torchtext._internal.module_utils import is_module_available
86
from torchtext.data.datasets_utils import (
97
_wrap_split_argument,
108
_create_dataset_directory,
119
)
1210

11+
if is_module_available("torchdata"):
12+
from torchdata.datapipes.iter import FileOpener, IterableWrapper
13+
from torchtext._download_hooks import HttpReader
14+
1315
URL = {
1416
"train": "https://www.clips.uantwerpen.be/conll2000/chunking/train.txt.gz",
1517
"test": "https://www.clips.uantwerpen.be/conll2000/chunking/test.txt.gz",

0 commit comments

Comments
 (0)