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

Enable custom default config for dataset tests #3578

Merged
merged 18 commits into from
Mar 22, 2021

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Mar 17, 2021

This came up in #3423 (comment).

TL;DR: With the current architecture, it is not possible to test a dataset that has a positional parameter, which should change depending on the config.

To overcome this, this PR makes the DEFAULT_CONFIG a first class member. It still defaults to the keyword arguments extracted from the dataset constructor, but can now be safely overwritten if needed.

@pmeier
Copy link
Collaborator Author

pmeier commented Mar 17, 2021

I've included some other documentation upgrades. If you want these in separate PRs, let me know.

@codecov
Copy link

codecov bot commented Mar 17, 2021

Codecov Report

Merging #3578 (c00c4d3) into master (bb2805a) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head c00c4d3 differs from pull request most recent head 085745e. Consider uploading reports for the commit 085745e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3578      +/-   ##
==========================================
- Coverage   79.07%   79.07%   -0.01%     
==========================================
  Files         105      105              
  Lines        9787     9786       -1     
  Branches     1572     1572              
==========================================
- Hits         7739     7738       -1     
  Misses       1567     1567              
  Partials      481      481              
Impacted Files Coverage Δ
torchvision/datasets/voc.py 94.44% <100.00%> (-0.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb2805a...085745e. Read the comment docs.

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks @pmeier , I made a few comments. I find the logic a bit tricky to follow overall, as the OO implementation is very stateful. It might not be worth considering a refactoring, but I think at least DEFAULT_CONFIG could be renamed in something more descriptive.

test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

There seems to be some confusion about how the configs are handled. I hope I can make it more clear with my comments.

test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks for these precisions @pmeier , I made a second pass

test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
@pmeier
Copy link
Collaborator Author

pmeier commented Mar 19, 2021

@NicolasHug

Following our internal discussion, I refactored a little more:

  • We now can have a DEFAULT_CONFIG as well as ADDITIONAL_CONFIGS. Neither of them need to be complete or will be overwritten.
  • test_all_configs will now also test the DEFAULT_CONFIG. By default it also tries to remove duplicate configs. If this fails, for example if a value is not hashable, it falls back to testing all configs.

Let me know what you think.

@pmeier pmeier requested a review from NicolasHug March 19, 2021 08:46
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks @pmeier , some last comments but LGTM!

test/datasets_utils.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
test/datasets_utils.py Outdated Show resolved Hide resolved
@pmeier
Copy link
Collaborator Author

pmeier commented Mar 22, 2021

@NicolasHug I've addressed all your comments. Thanks a lot for the input! IMO it made the PR a lot better 🙂 Merge if you and the CI are happy.

@NicolasHug
Copy link
Member

Thanks @pmeier !
I think the CI failures are unrelated

@NicolasHug NicolasHug merged commit 09600b9 into pytorch:master Mar 22, 2021
@pmeier pmeier deleted the fix-default-config branch March 22, 2021 08:17
facebook-github-bot pushed a commit that referenced this pull request Apr 1, 2021
Reviewed By: fmassa

Differential Revision: D27433915

fbshipit-source-id: 70d5fcd0a8b68c2de7362ddf4f63a072cf658d7c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants