Skip to content

Loosening Some Ruff Ignores#405

Merged
emersodb merged 6 commits into
mainfrom
dbe/loosening_some_ruff_ignores
Jun 21, 2025
Merged

Loosening Some Ruff Ignores#405
emersodb merged 6 commits into
mainfrom
dbe/loosening_some_ruff_ignores

Conversation

@emersodb

@emersodb emersodb commented Jun 20, 2025

Copy link
Copy Markdown
Collaborator

PR Type

Other

Short Description

This PR removes some of the Ruff ignores that we have in place and fixes the issues that arise in our code base by doing so. Namely, applying the Ruff rules

  • D107: No undocumented public functions
  • D417: No undocumented parameters in the args section of docstrings
  • D105: No undocumented public init functions
  • PLR2004: No magic numbers

Note: We do not enforce various ruff rules in our examples, tests, and research folders. Below is a justification for the settings I chose in these folders.

# Ignoring undocumented public functions, public init, magic method, and magic numbers
"tests/*" = ["D103", "D105", "D107", "PLR2004"]

In the tests, there is good justification for having magic numbers. We also create a lot of helper functions, classes, and magic methods meant to facilitate testing that would be very annoying (and many would be unnecessary) to document formally.

# Ignoring undocumented, public init, magic method, and magic numbers
"research/*" = ["PLR2004", "D105", "D107"]

Our research folders are meant to be less formal. It's nice to have documentation where helpful to someone using the code, but things like public init documentation, magic method descriptions, and magic numbers aren't exceptionally important.

# Ignoring undocumented public init
"examples/*" = ["D107"]

Each time we want to perform FL training, we override the server and client base classes to produce customized training flows. Documenting these is unnecessary and we have README files that discuss the point of each example and how to run it.

Tests Added

NA

@codecov

codecov Bot commented Jun 20, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 92.10526% with 3 lines in your changes missing coverage. Please review.

Project coverage is 79.88%. Comparing base (3f50d8f) to head (f08602c).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...bases/masked_layers/masked_normalization_layers.py 66.66% 2 Missing ⚠️
fl4health/clients/flexible_client.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #405      +/-   ##
==========================================
+ Coverage   79.85%   79.88%   +0.03%     
==========================================
  Files         158      158              
  Lines        9540     9556      +16     
==========================================
+ Hits         7618     7634      +16     
  Misses       1922     1922              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# As the linked issue above points out, calling gc.freeze() greatly reduces the
# overhead of garbage collection. (from 1.5s to 0.005s)
if current_server_round == 2:
if current_server_round == 2: # noqa: PLR2004

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This magic number is sort of hard to describe in a concise name... So applying an ignore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

<some-thing>_STARTING_ROUND? lol

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah...it has to do with when we want to start doing GC in a special way to avoid memory overloading. It's very niche 😂

@emersodb emersodb marked this pull request as ready for review June 20, 2025 15:50

@nerdai nerdai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Justifications seem sensible to me.

@fatemetkl fatemetkl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@emersodb emersodb merged commit 9bc9d42 into main Jun 21, 2025
10 checks passed
@emersodb emersodb deleted the dbe/loosening_some_ruff_ignores branch June 21, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants