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

Bugfix/_has_len #2307

Merged
merged 28 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0d0dcff
deal with NotImplementedError raised by torchtext
Jun 19, 2020
2cbaa3e
deal with NotImplementedError raised by torchtext
Jun 19, 2020
490b86a
Merge branch 'bugfix/_has_len' of https://github.com/thschaaf/pytorch…
Jun 19, 2020
2f40577
Added tests for dataloader which raise NotImplementedError in __len__()
Jun 19, 2020
1e7f096
Fixed some typos
Jun 19, 2020
61c0a83
enabled tests for dataloader raising NotImplementedError in __len__ a…
Jun 20, 2020
8d7523f
Merge remote-tracking branch 'origin/master' into bugfix/_has_len
Jun 20, 2020
975b374
deleted empty line for style compliance
Jun 20, 2020
89e6d5e
refactored CustomNotImplementedErrorDataloader to derive from CustomI…
Jun 21, 2020
e5e68bb
enabled reduced number of not_implemented_error dataloader test to re…
Jun 21, 2020
4db26e6
reduced test number of not_implemented_error dataloader test further …
Jun 21, 2020
5b6413e
reduced test number of not_implemented_error dataloader test to one t…
Jun 21, 2020
8a04b7c
disabled all not_implemented_error dataloader test to see if test pas…
Jun 21, 2020
19522fc
added __next__ with a reduced number (5) of elements after which Cust…
Jun 21, 2020
f480072
enabling all not_implemented_error dataloader test
Jun 21, 2020
7e06de0
added brief description of change and relation of torchtext
Jun 21, 2020
d495334
CustomNotImplementedErrorDataloader reduced number of batches served …
Jun 22, 2020
17bcc79
Update CHANGELOG.md
thschaaf Jun 22, 2020
4784417
Apply suggestions from code review
Borda Jun 22, 2020
a41a441
Update CHANGELOG.md
thschaaf Jun 22, 2020
3e4ad2f
Disable parallelism in dataloader
Jun 22, 2020
cf982bf
added max_steps=None to Trainer in not_implemented_error dataloader t…
Jun 22, 2020
8ac3e86
rearranged not_implemented_error test in file to group them together
Jun 23, 2020
77b613c
disabled parallel data loading
Jun 23, 2020
413b06d
Apply suggestions from code review
Borda Jun 23, 2020
907893e
Merge branch 'master' into bugfix/_has_len
thschaaf Jun 23, 2020
c96cd9b
Merge branch 'master' into bugfix/_has_len
thschaaf Jun 23, 2020
fa695c4
Apply suggestions from code review
Borda Jun 23, 2020
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
21 changes: 1 addition & 20 deletions tests/base/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,8 @@ def __next__(self):
return next(self.iter)


class CustomNotImplementedErrorDataloader:

def __init__(self, dataloader):
self.dataloader = dataloader
self.iter = iter(dataloader)
self.count = 0
class CustomNotImplementedErrorDataloader(CustomInfDataloader):

def __len__(self):
"""raise NotImplementedError"""
raise NotImplementedError

def __iter__(self):
self.count = 0
return self

def __next__(self):
if self.count >= 50:
raise StopIteration
self.count = self.count + 1
try:
return next(self.iter)
except StopIteration:
self.iter = iter(self.dataloader)
return next(self.iter)
8 changes: 4 additions & 4 deletions tests/trainer/test_dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def test_train_not_implemented_error_dataloader_error(tmpdir):

trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, val_check_interval=0.5)

with pytest.raises(MisconfigurationException, match='not_implemented_error DataLoader'):
with pytest.raises(MisconfigurationException, match='infinite DataLoader'):
trainer.fit(model)


Expand All @@ -327,7 +327,7 @@ def test_val_not_implemented_error_dataloader_error(tmpdir):

trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, limit_val_batches=0.5)

with pytest.raises(MisconfigurationException, match='not_implemented_error DataLoader'):
with pytest.raises(MisconfigurationException, match='infinite DataLoader'):
trainer.fit(model)


Expand All @@ -351,7 +351,7 @@ def test_test_not_implemented_error_dataloader_error(tmpdir):

trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, limit_test_batches=0.5)

with pytest.raises(MisconfigurationException, match='not_implemented_error DataLoader'):
with pytest.raises(MisconfigurationException, match='infinite DataLoader'):
trainer.test(model)


Expand Down Expand Up @@ -413,7 +413,7 @@ def test_inf_val_dataloader(tmpdir, check_interval):

@pytest.mark.parametrize('check_interval', [1.0])
@pytest.mark.skip('TODO: speed up this test')
def test_not_implemented_error_dataloader(tmpdir, check_interval):
def test_not_implemented_error_val_dataloader(tmpdir, check_interval):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, no test for "not implemented error"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the test refers CustomNotImplementedErrorDataloader which raises a NotImplementedError when len is called. In this configuration training should take place. I am open for name suggestions.

"""Test not_implemented_error data loader (e.g. IterableDataset)"""

model = EvalModelTemplate()
Expand Down