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

Refactor: Imports #1681

Merged
merged 8 commits into from
Apr 4, 2023
Merged

Refactor: Imports #1681

merged 8 commits into from
Apr 4, 2023

Conversation

SkafteNicki
Copy link
Member

What does this PR do?

Fixes #1654

The following is kept in root:

  • All regression + classification metrics
  • Metric and MetricCollection
  • All simple aggregation metrics: SumMetric, MeanMetric etc.

Rest should be imported from domain.

Before submitting
  • Was this discussed/agreed 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?
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 🙃

@SkafteNicki SkafteNicki added the refactoring refactoring and code health label Apr 3, 2023
@SkafteNicki SkafteNicki added this to the v0.12 milestone Apr 3, 2023
@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Merging #1681 (f78c894) into master (9d3a7cc) will decrease coverage by 28%.
The diff coverage is n/a.

❗ Current head f78c894 differs from pull request most recent head 5b85077. Consider uploading reports for the commit 5b85077 to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1681     +/-   ##
========================================
- Coverage      89%     61%    -28%     
========================================
  Files         228     228             
  Lines       12796   12796             
========================================
- Hits        11363    7796   -3567     
- Misses       1433    5000   +3567     

@Borda Borda requested a review from lantiga April 3, 2023 07:43
@mergify mergify bot requested a review from a team April 3, 2023 07:43
@lantiga
Copy link
Contributor

lantiga commented Apr 3, 2023

TorchMetrics has extremely widespread use. I know we are heading towards 1.0 etc, but I would be very conservative here.

I'm in favor of pushing users to import from sub-packages, but I don't think we should wholesale remove root imports just yet. This has a 100% chance of breaking a lot of people's code, and these people don't necessarily care about 0.11 vs 1.0.

I would keep root imports in place and just produce deprecation warnings until 2.0.

@Borda
Copy link
Member

Borda commented Apr 3, 2023

I would keep root imports in place and just produce deprecation warnings until 2.0

ok, this would effectively mean we would create a wrapper class for each of them so also confusing for developers that they won't import Accuracy but AccuracyDeprecatedImport

source torchmetrics/image/tv.py

class TotalVariation(Metric):
  ... # the actual implementation

class TotalVariationDeprecatedImport(TotalVariation):

	def __init__(...):
		raise DeprecationWarning(...)
		super().__init__(...)

and for imports: torchmetrics/image/__init__.py

from torchmetrics.image.tv import TotalVariation

and torchmetrics/__init__.py

from torchmetrics.image.tv import TotalVariationDeprecatedImport as TotalVariation

@Borda Borda marked this pull request as draft April 4, 2023 12:01
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

lets keep it as updating docstrings

@Borda Borda marked this pull request as ready for review April 4, 2023 18:18
@Borda Borda enabled auto-merge (squash) April 4, 2023 18:38
@mergify mergify bot added the ready label Apr 4, 2023
@Borda Borda disabled auto-merge April 4, 2023 23:06
@Borda Borda merged commit dd1df84 into master Apr 4, 2023
@Borda Borda deleted the refactor/imports branch April 4, 2023 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready refactoring refactoring and code health
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent imports for BLEUScore and ROUGEScore
4 participants