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] MetricCollection should return metrics with prefix on items(), keys() #209

Merged
merged 30 commits into from
May 4, 2021

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Apr 28, 2021

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 to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

This PR makes sure items() / keys() properly returns the right keys with prefix / postfix.

Fixes #Lightning-AI/pytorch-lightning#7235.

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 🙃

@tchaton tchaton added this to the v0.4 milestone Apr 28, 2021
@tchaton tchaton self-assigned this Apr 28, 2021
@pep8speaks
Copy link

pep8speaks commented Apr 28, 2021

Hello @tchaton! Thanks for updating this PR.

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

Comment last updated at 2021-05-03 20:05:29 UTC

@tchaton tchaton requested a review from edenlightning as a code owner April 28, 2021 16:19
@codecov
Copy link

codecov bot commented Apr 28, 2021

Codecov Report

Merging #209 (a1596a6) into master (7a9e50a) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #209      +/-   ##
==========================================
+ Coverage   96.73%   96.76%   +0.02%     
==========================================
  Files         184      184              
  Lines        5888     5930      +42     
==========================================
+ Hits         5696     5738      +42     
  Misses        192      192              
Flag Coverage Δ
Linux 79.66% <55.55%> (-0.17%) ⬇️
Windows 79.66% <55.55%> (-0.17%) ⬇️
cpu 96.76% <100.00%> (+0.02%) ⬆️
gpu 96.76% <ø> (+0.02%) ⬆️
macOS 96.76% <100.00%> (+0.02%) ⬆️
pytest 96.76% <100.00%> (+0.02%) ⬆️
python3.6 95.69% <100.00%> (+0.03%) ⬆️
python3.8 96.72% <100.00%> (+0.02%) ⬆️
python3.9 ?
torch1.3.1 95.69% <100.00%> (+0.03%) ⬆️
torch1.4.0 95.81% <100.00%> (+0.02%) ⬆️
torch1.8.1 96.62% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
torchmetrics/collections.py 98.82% <100.00%> (+0.38%) ⬆️
__w/2/s/torchmetrics/collections.py 98.82% <0.00%> (+0.38%) ⬆️

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 7a9e50a...a1596a6. Read the comment docs.

@itsikad
Copy link

itsikad commented Apr 28, 2021

Thanks @tchaton

I'm probably missing something here, but why not changing the clone method such that it adds prefix/postfix to the returned dictionary keys?

Copy link
Member

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

LGTM

@Borda Borda added the bug / fix Something isn't working label Apr 28, 2021
@Borda Borda modified the milestones: v0.4, v0.3 Apr 28, 2021
Borda and others added 4 commits April 28, 2021 19:59
* update pre-commit

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
* fix setup imports

* pkg
Borda
Borda previously approved these changes Apr 28, 2021
@Borda Borda enabled auto-merge (squash) April 28, 2021 18:04
@Borda Borda requested a review from carmocca April 29, 2021 08:14
@Borda Borda dismissed carmocca’s stale review April 29, 2021 08:15

pls check last version

@SkafteNicki SkafteNicki enabled auto-merge (squash) April 29, 2021 12:26
@maximsch2
Copy link
Contributor

@tchaton , I agree that we should fix the checkpointing behavior, but my point is that it might be cleaner to just change the clone method so that the new collection actually has the keys with prefixes inside, that way we don't have to have hacks that pretend otherwise at run time.

@tchaton
Copy link
Contributor Author

tchaton commented Apr 30, 2021

@tchaton , I agree that we should fix the checkpointing behavior, but my point is that it might be cleaner to just change the clone method so that the new collection actually has the keys with prefixes inside, that way we don't have to have hacks that pretend otherwise at run time.

Hey @SkafteNicki. What are your thoughts ? Happy to let someone else change the MetricCollection to save the metrics with prefix and postfix directly.

Best,
T.C

@SkafteNicki
Copy link
Member

@tchaton I am in favour of this change so the keys are consistent between .items(), .keys() and the dics returned by forward and .compute()

@Borda Borda self-requested a review May 3, 2021 17:16
@mergify mergify bot added the has conflicts label May 3, 2021
@mergify mergify bot removed the has conflicts label May 3, 2021
@maximsch2
Copy link
Contributor

Actually I now think this is fine - we can just flip the implementation later and just do the in-place modification in case of keep_base=True.

lgtm

@Borda
Copy link
Member

Borda commented May 4, 2021

Actually I now think this is fine - we can just flip the implementation later and just do the in-place modification in case of keep_base=True.

so pls make an issue for it for this milestone so we do not forget it... (and link it in this PR)

@SkafteNicki SkafteNicki merged commit 67ce961 into master May 4, 2021
@SkafteNicki SkafteNicki deleted the metrics_collection branch May 4, 2021 10:01
Borda pushed a commit that referenced this pull request May 10, 2021
…), keys() (#209)

* update

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update print

* resolve flake8

* update

* CI: update pre-commit (#207)

* update pre-commit

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>

* fix setup imports (#208)

* fix setup imports

* pkg

* chlog

* format

* update

* update

* check type

* update on comments

* update on comments

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: jirka <jirka.borovec@seznam.cz>
(cherry picked from commit 67ce961)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants