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

Fix import error #2252

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 2 additions & 6 deletions torchtext/datasets/cnndm.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ def _hash_urls(s: tuple):


def _get_split_list(source: str, split: str):
from torchdata.datapipes.iter import IterableWrapper, OnlineReader # noqa
url_dp = IterableWrapper([SPLIT_LIST[source + "_" + split]])
online_dp = OnlineReader(url_dp)
return online_dp.readlines().map(fn=_hash_urls)


def _load_stories(root: str, source: str, split: str):
from torchdata.datapipes.iter import FileOpener, IterableWrapper, GDriveReader # noqa
split_list = set(_get_split_list(source, split))
story_dp = IterableWrapper([URL[source]])
cache_compressed_dp = story_dp.on_disk_cache(
Expand Down Expand Up @@ -135,12 +137,6 @@ def CNNDM(root: str, split: Union[Tuple[str], str]):
raise ModuleNotFoundError(
"Package `torchdata` not found. Please install following instructions at https://github.com/pytorch/data"
)
from torchdata.datapipes.iter import ( # noqa
FileOpener,
IterableWrapper,
OnlineReader,
GDriveReader,
)

cnn_dp = _load_stories(root, "cnn", split)
dailymail_dp = _load_stories(root, "dailymail", split)
Expand Down