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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn user when IterableDataset has __len__ defined #2437

Merged
merged 11 commits into from
Jul 1, 2020

Conversation

awaelchli
Copy link
Member

@awaelchli awaelchli commented Jun 30, 2020

What does this PR do?

Fixes #2429

torch < 1.4: An IterableDataset with __len__ defined raises a TypeError
torch >= 1.4: It does not raise an error, but we still want to display a warning because it is most likely unintentional and could lead to side effects.

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 馃檭

@awaelchli awaelchli linked an issue Jun 30, 2020 that may be closed by this pull request
@mergify mergify bot requested a review from a team June 30, 2020 23:13
@awaelchli awaelchli added the bug Something isn't working label Jun 30, 2020
@awaelchli awaelchli changed the title fix should_check_val flag for iterable dataset that has __len__ defined Warn user when IterableDataset has __len__ defined Jul 1, 2020
@awaelchli awaelchli added feature Is an improvement or enhancement and removed bug Something isn't working labels Jul 1, 2020
@codecov
Copy link

codecov bot commented Jul 1, 2020

Codecov Report

Merging #2437 into master will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #2437   +/-   ##
======================================
  Coverage      88%     88%           
======================================
  Files          69      69           
  Lines        5526    5527    +1     
======================================
+ Hits         4887    4888    +1     
  Misses        639     639           

@pep8speaks
Copy link

pep8speaks commented Jul 1, 2020

Hello @awaelchli! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 馃嵒

Comment last updated at 2020-07-01 11:33:06 UTC

@mergify mergify bot requested a review from a team July 1, 2020 04:58
@awaelchli awaelchli marked this pull request as ready for review July 1, 2020 05:56
@@ -41,19 +43,33 @@
HOROVOD_AVAILABLE = True


def _has_iterable_dataset(dataloader: DataLoader):
return ITERABLE_DATASET_EXISTS and hasattr(dataloader, 'dataset') \
Copy link
Member

Choose a reason for hiding this comment

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

if you encapsulate the if statement in () you do not need to use \

Comment on lines 61 to +64
except TypeError:
return False
has_len = False
except NotImplementedError: # e.g. raised by torchtext if a batch_size_fn is used
return False
has_len = False
Copy link
Member

Choose a reason for hiding this comment

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

if the resulting action is the same, lets write it in one

    except (TypeError, NotImplementedError):  # e.g. raised by torchtext if a batch_size_fn is used
        has_len = False

pytorch_lightning/trainer/data_loading.py Outdated Show resolved Hide resolved
requirements/base.txt Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team July 1, 2020 06:30
williamFalcon and others added 3 commits July 1, 2020 06:18
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
@williamFalcon williamFalcon merged commit 927f305 into master Jul 1, 2020
@Borda Borda deleted the bugfix/should_check_val branch July 1, 2020 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Batched iterative dataloading disables validation
5 participants