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

Lazy import text #2216

Merged
merged 8 commits into from
Nov 27, 2023
Merged

Lazy import text #2216

merged 8 commits into from
Nov 27, 2023

Conversation

SkafteNicki
Copy link
Member

@SkafteNicki SkafteNicki commented Nov 14, 2023

What does this PR do?

Fixes part of #2171
Fixes #2242

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 🙃


📚 Documentation preview 📚: https://torchmetrics--2216.org.readthedocs.build/en/2216/

@SkafteNicki SkafteNicki added the enhancement New feature or request label Nov 14, 2023
@SkafteNicki SkafteNicki added this to the v1.3.0 milestone Nov 14, 2023
@SkafteNicki SkafteNicki self-assigned this Nov 14, 2023
@Borda Borda marked this pull request as draft November 21, 2023 14:01
@Borda Borda added the refactoring refactoring and code health label Nov 21, 2023
@SkafteNicki SkafteNicki marked this pull request as ready for review November 25, 2023 18:15
Copy link

codecov bot commented Nov 25, 2023

Codecov Report

Merging #2216 (4e809fe) into master (8ef2a89) will decrease coverage by 45%.
The diff coverage is 67%.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #2216     +/-   ##
========================================
- Coverage      87%     42%    -45%     
========================================
  Files         293     293             
  Lines       16423   16426      +3     
========================================
- Hits        14279    6847   -7432     
- Misses       2144    9579   +7435     

@mergify mergify bot added the ready label Nov 25, 2023
Comment on lines +27 to +30
if _TQDM_AVAILABLE:
import tqdm
if _TRANSFORMERS_GREATER_EQUAL_4_4:
from transformers import PreTrainedModel, PreTrainedTokenizerBase
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK, under TYPE_CHECKING the other checks do not matter

Suggested change
if _TQDM_AVAILABLE:
import tqdm
if _TRANSFORMERS_GREATER_EQUAL_4_4:
from transformers import PreTrainedModel, PreTrainedTokenizerBase
import tqdm
from transformers import PreTrainedModel, PreTrainedTokenizerBase

@carmocca carmocca merged commit bb024f6 into master Nov 27, 2023
61 checks passed
@carmocca carmocca deleted the lazy_text branch November 27, 2023 12:47
Borda pushed a commit that referenced this pull request Nov 30, 2023
(cherry picked from commit bb024f6)
Borda pushed a commit that referenced this pull request Dec 1, 2023
(cherry picked from commit bb024f6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready refactoring refactoring and code health topic: Text
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HF transformers is always imported at __init__ if available
3 participants