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

use ruff for linting and formatting, update CI #978

Merged
merged 21 commits into from
Mar 12, 2024
Merged

Conversation

janfb
Copy link
Contributor

@janfb janfb commented Mar 6, 2024

Main changes

  • replace black, isort and flake by ruff in pyproject.toml
  • update pre-commit hooks
  • update CI workflow similar to zuko
    • add pre-commit hooks
    • add option to add multiple python and torch versions in parallel (only 3.10 and torch 1.11 and 2.2)
  • fix all ruff errors so that we can introduce ruff linting and formatting in pre-commit hooks for the hackathon

Why are there so many changed files?

  • applied pre-commit fixes: trailing whitespaces and empty lines
  • applied automatic linting fixes: ruff check --fix to sbi/, examples/ tutorials/ tests/
  • applied automatic formatting fixes: ruff format .
  • I fixed around 200 ruff check . errors manually 😵

fixes #934
fixes #959
fixes #960

Notes for reviewing

As there are so many file changes, I recommend reviewing the individual commits separately. I tried to group changes into specific commits.

  • slow tests are passing locally
  • GPU tests are passing for MPS and CUDA.

@janfb janfb force-pushed the add-ruff-and-update-ci branch 2 times, most recently from 7c3392d to 2cdca6b Compare March 6, 2024 10:56
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 69.76744% with 39 lines in your changes are missing coverage. Please review.

Project coverage is 76.28%. Comparing base (17f3033) to head (246c8b0).

Files Patch % Lines
sbi/analysis/plot.py 59.09% 9 Missing ⚠️
sbi/utils/user_input_checks.py 11.11% 8 Missing ⚠️
sbi/inference/abc/smcabc.py 0.00% 3 Missing ⚠️
sbi/neural_nets/flow.py 72.72% 3 Missing ⚠️
sbi/samplers/mcmc/mcmc.py 0.00% 3 Missing ⚠️
sbi/utils/posterior_ensemble.py 0.00% 3 Missing ⚠️
sbi/inference/base.py 50.00% 2 Missing ⚠️
sbi/inference/snpe/snpe_base.py 33.33% 2 Missing ⚠️
sbi/samplers/vi/vi_utils.py 66.66% 2 Missing ⚠️
sbi/inference/posteriors/base_posterior.py 0.00% 1 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #978      +/-   ##
==========================================
+ Coverage   76.17%   76.28%   +0.10%     
==========================================
  Files          83       83              
  Lines        6406     6384      -22     
==========================================
- Hits         4880     4870      -10     
+ Misses       1526     1514      -12     
Flag Coverage Δ
unittests 76.28% <69.76%> (+0.10%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@janfb janfb force-pushed the add-ruff-and-update-ci branch 3 times, most recently from dbe58f5 to 0df847d Compare March 7, 2024 09:43
@janfb janfb added this to the Pre Hackathon 2024 milestone Mar 7, 2024
@janfb janfb added documentation Improvements or additions to documentation hackathon labels Mar 7, 2024
@janfb janfb self-assigned this Mar 7, 2024
Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

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

Thanks a lot! I did not go through tests and tutorials, but left some comments on the rest.

docs/docs/faq/question_07_custom_prior.md Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
sbi/analysis/conditional_density.py Outdated Show resolved Hide resolved
sbi/analysis/sbc.py Outdated Show resolved Hide resolved
sbi/inference/base.py Outdated Show resolved Hide resolved
sbi/inference/posteriors/vi_posterior.py Outdated Show resolved Hide resolved
sbi/utils/conditional_density_utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

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

Thanks!

@janfb janfb changed the title Add ruff and update ci add ruff for linting and formatting, update CI Mar 12, 2024
@janfb janfb changed the title add ruff for linting and formatting, update CI use ruff for linting and formatting, update CI Mar 12, 2024
@janfb janfb merged commit 9c307cf into main Mar 12, 2024
4 of 5 checks passed
@janfb janfb deleted the add-ruff-and-update-ci branch March 12, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation hackathon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix ruff linting in notebooks 🏅 fix ruff linting errors 🏅 Switch to ruff for linting and formatting
2 participants