Skip to content

use ruff for linting and formatting, update CI - #978

Merged
janfb merged 21 commits into
mainfrom
add-ruff-and-update-ci
Mar 12, 2024
Merged

janfb merged 21 commits into
mainfrom
add-ruff-and-update-ci

Conversation

@janfb

@janfb janfb commented Mar 6, 2024 •

Copy link
Copy Markdown
Contributor

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
@codecov

codecov Bot commented Mar 6, 2024 •

Copy link
Copy Markdown

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 from cfd5849 to 32978c9 Compare March 6, 2024 12:26
@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 requested a review from michaeldeistler March 7, 2024 09:55
@janfb janfb added this to the Pre Hackathon 2024 milestone Mar 7, 2024
@janfb janfb added docs Improvements or additions to documentation hackathon For our in-person hackathons with maintainers present, not a general up-for-grabs list labels Mar 7, 2024
@janfb janfb self-assigned this Mar 7, 2024
@janfb
janfb force-pushed the add-ruff-and-update-ci branch from 0df847d to c83e095 Compare March 7, 2024 09:58

@michaeldeistler michaeldeistler left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread pyproject.toml Resolved
Comment thread sbi/analysis/conditional_density.py Resolved
Comment thread sbi/analysis/sbc.py Resolved
Comment thread sbi/inference/base.py Resolved
Comment thread sbi/utils/conditional_density_utils.py Resolved
@janfb
janfb requested a review from michaeldeistler March 11, 2024 16:15

@michaeldeistler michaeldeistler left a comment

Copy link
Copy Markdown
Contributor

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 force-pushed the add-ruff-and-update-ci branch from afe00fc to 246c8b0 Compare March 12, 2024 10:29
@janfb
janfb merged commit 9c307cf into main Mar 12, 2024
@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

docs Improvements or additions to documentation hackathon For our in-person hackathons with maintainers present, not a general up-for-grabs list

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