Skip to content

Fix Mock tests due to change in datasets directory #1749

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

Merged
merged 1 commit into from
May 27, 2022
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
2 changes: 1 addition & 1 deletion test/datasets/test_agnews.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TestAGNews(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
4 changes: 3 additions & 1 deletion test/datasets/test_amazonreviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def tearDownClass(cls):

@nested_params([AmazonReviewFull, AmazonReviewPolarity], ["train", "test"])
def test_amazon_reviews(self, amazon_review_dataset, split):
expected_samples = _get_mock_dataset(self.root_dir, amazon_review_dataset.__name__)[split]
expected_samples = _get_mock_dataset(os.path.join(self.root_dir, "datasets"), amazon_review_dataset.__name__)[
split
]
dataset = amazon_review_dataset(root=self.root_dir, split=split)
samples = list(dataset)

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_cc100.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TestCC100(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_cola.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TestCoLA(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_conll2000chunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TestCoNLL2000Chunking(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_dbpedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TestDBpedia(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_enwik9.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TestEnWik9(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TestIMDB(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
6 changes: 4 additions & 2 deletions test/datasets/test_iwslt2016.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def tearDownClass(cls):
def test_iwslt2016(self, split, src, tgt, dev_set, test_set):

with tempfile.TemporaryDirectory() as root_dir:
expected_samples = _get_mock_dataset(root_dir, split, src, tgt, dev_set, test_set)
expected_samples = _get_mock_dataset(os.path.join(root_dir, "datasets"), split, src, tgt, dev_set, test_set)

dataset = IWSLT2016(
root=root_dir,
Expand All @@ -185,7 +185,9 @@ def test_iwslt2016_split_argument(self, split):
language_pair = ("de", "en")
valid_set = "tst2013"
test_set = "tst2014"
_ = _get_mock_dataset(root_dir, split, language_pair[0], language_pair[1], valid_set, test_set)
_ = _get_mock_dataset(
os.path.join(root_dir, "datasets"), split, language_pair[0], language_pair[1], valid_set, test_set
)
dataset1 = IWSLT2016(
root=root_dir,
split=split,
Expand Down
8 changes: 6 additions & 2 deletions test/datasets/test_iwslt2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ def tearDownClass(cls):
def test_iwslt2017(self, split, src, tgt):

with tempfile.TemporaryDirectory() as root_dir:
expected_samples = _get_mock_dataset(root_dir, split, src, tgt, "dev2010", "tst2010")
expected_samples = _get_mock_dataset(
os.path.join(root_dir, "datasets"), split, src, tgt, "dev2010", "tst2010"
)

dataset = IWSLT2017(root=root_dir, split=split, language_pair=(src, tgt))

Expand All @@ -170,7 +172,9 @@ def test_iwslt2017_split_argument(self, split):
language_pair = ("de", "en")
valid_set = "dev2010"
test_set = "tst2010"
_ = _get_mock_dataset(root_dir, split, language_pair[0], language_pair[1], valid_set, test_set)
_ = _get_mock_dataset(
os.path.join(root_dir, "datasets"), split, language_pair[0], language_pair[1], valid_set, test_set
)
dataset1 = IWSLT2017(root=root_dir, split=split, language_pair=language_pair)
(dataset2,) = IWSLT2017(root=root_dir, split=(split,), language_pair=language_pair)

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_mnli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TestMNLI(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_mrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TestMRPC(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_multi30k.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TestMulti30k(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_penntreebank.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TestPennTreebank(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_qqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TestQQP(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_sogounews.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestSogouNews(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_squads.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def tearDownClass(cls):

@nested_params([SQuAD1, SQuAD2], ["train", "dev"])
def test_squads(self, squad_dataset, split):
expected_samples = _get_mock_dataset(self.root_dir, squad_dataset.__name__)[split]
expected_samples = _get_mock_dataset(os.path.join(self.root_dir, "datasets"), squad_dataset.__name__)[split]
dataset = squad_dataset(root=self.root_dir, split=split)
samples = list(dataset)

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_sst2.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestSST2(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_stsb.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TestSTSB(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_udpos.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TestUDPOS(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
4 changes: 3 additions & 1 deletion test/datasets/test_wikitexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def tearDownClass(cls):

@nested_params([WikiText103, WikiText2], ["train", "valid", "test"])
def test_wikitexts(self, wikitext_dataset, split):
expected_samples = _get_mock_dataset(self.root_dir, base_dir_name=wikitext_dataset.__name__)[split]
expected_samples = _get_mock_dataset(
os.path.join(self.root_dir, "datasets"), base_dir_name=wikitext_dataset.__name__
)[split]

dataset = wikitext_dataset(root=self.root_dir, split=split)
samples = list(dataset)
Expand Down
2 changes: 1 addition & 1 deletion test/datasets/test_yahooanswers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestYahooAnswers(TempDirMixin, TorchtextTestCase):
def setUpClass(cls):
super().setUpClass()
cls.root_dir = cls.get_base_temp_dir()
cls.samples = _get_mock_dataset(cls.root_dir)
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
cls.patcher.start()

Expand Down
4 changes: 3 additions & 1 deletion test/datasets/test_yelpreviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def tearDownClass(cls):

@nested_params([YelpReviewPolarity, YelpReviewFull], ["train", "test"])
def test_yelpreviews(self, yelp_dataset, split):
expected_samples = _get_mock_dataset(self.root_dir, base_dir_name=yelp_dataset.__name__)[split]
expected_samples = _get_mock_dataset(
os.path.join(self.root_dir, "datasets"), base_dir_name=yelp_dataset.__name__
)[split]

dataset = yelp_dataset(root=self.root_dir, split=split)
samples = list(dataset)
Expand Down