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

fix compatibility for pytest 8 #20575

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

haifeng-jin
Copy link

@haifeng-jin haifeng-jin commented Feb 5, 2025

What does this PR do?

The test test_seed_stays_same_with_multiple_seed_everything_calls is only compatible with pytest==7, but not pytest==8 due to its passing None to pytest.warns(), which is deprecated.

This PR fixes the test by making it compatible with both pytest 7 & 8.

more context:
We (Google) uses a monorepo that enforces the pytest version to be 8 for now.
We want to be able to run the unit tests instead of just importing the code.
So, we would like to make this compatibility fix.

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • 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?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--20575.org.readthedocs.build/en/20575/

@github-actions github-actions bot added the fabric lightning.fabric.Fabric label Feb 5, 2025
Comment on lines +34 to +35
with warnings.catch_warnings():
warnings.simplefilter("error")
Copy link
Member

Choose a reason for hiding this comment

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

this seems like just a filter, but the original code validates that no warning was raised...

Copy link
Author

Choose a reason for hiding this comment

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

Hi Borda,

According to the doc, the simplefilter("error") would turn any warning into an error.

So, when a warning occurs, the test would error out.

Copy link
Collaborator

Choose a reason for hiding this comment

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

looks good to me, good use of catch_warnings to reset behavior back to default outside the context manager

Comment on lines +34 to +35
with warnings.catch_warnings():
warnings.simplefilter("error")
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks good to me, good use of catch_warnings to reset behavior back to default outside the context manager

@mergify mergify bot added the ready PRs ready to be merged label Feb 18, 2025
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49%. Comparing base (ea59e40) to head (d55923d).
Report is 4 commits behind head on master.

❌ Your project check has failed because the head coverage (49%) is below the target coverage (99%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (ea59e40) and HEAD (d55923d). Click for more details.

HEAD has 2265 uploads less than BASE
Flag BASE (ea59e40) HEAD (d55923d)
cpu 525 24
lightning_fabric 67 7
pytest 266 26
python3.9 132 6
lightning 394 19
python3.10 66 3
python3.11 132 6
python3.12.7 195 9
pytorch2.1 99 0
pytest-full 261 0
pytorch2.2.2 33 0
pytorch_lightning 66 0
pytorch2.3 33 0
pytorch2.4.1 31 0
pytorch2.5.1 65 0
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #20575     +/-   ##
=========================================
- Coverage      88%      49%    -39%     
=========================================
  Files         267      264      -3     
  Lines       23380    23324     -56     
=========================================
- Hits        20481    11382   -9099     
- Misses       2899    11942   +9043     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fabric lightning.fabric.Fabric ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants