Skip to content

chore(ci): make ruff lint clean so CI passes#1

Merged
hallelx2 merged 2 commits into
masterfrom
halleluyaholudele/hal-302-ruff-ci-clean
Jun 13, 2026
Merged

chore(ci): make ruff lint clean so CI passes#1
hallelx2 merged 2 commits into
masterfrom
halleluyaholudele/hal-302-ruff-ci-clean

Conversation

@hallelx2

@hallelx2 hallelx2 commented Jun 13, 2026

Copy link
Copy Markdown
Owner

What

Gets the CI lint job green. After the v0.3.0 release the ruff check . step was failing on 35 findings; this resolves all of them.

How

  • Config, not silencing bugs. Ignore three deliberate stylistic rules that are pervasive (and readable) in the benchmark/experiment/test code:
    • E731 lambda assignment — used for one-line closures (plain = lambda: F.mse_loss(model(x), y)).
    • E701/E702 compound one-liners — tight timing blocks (t0 = ...; r = s.search(); wall = ...).
  • Exclude non-library dirs from linting: notebooks/ (demo cell code), paper/, results/ (build artifacts).
  • Real autofixes applied: dropped unused imports and split multi-import lines (import os, sys → one per line). Notebooks also gained standard nbformat cell id fields.
  • One genuine fix: removed a dead wrapped local in test_best_so_far_only_decreases (F841).

Verification

  • ruff check .All checks passed!
  • pytest tests/test_benchmark_budget.py → 7 passed.

Closes HAL-302

Summary by Sourcery

Align linting configuration and code style with Ruff to restore a clean CI lint job without changing runtime behavior.

Bug Fixes:

  • Remove an unused local variable in test_best_so_far_only_decreases to satisfy Ruff and avoid dead-code confusion.

Enhancements:

  • Update Ruff configuration to ignore selected stylistic rules and exclude non-library directories such as notebooks, paper, and results from linting.
  • Apply non-functional style cleanups across notebooks and code, including splitting multi-import statements and adding standard cell IDs to notebooks for compatibility.

- Configure ruff to ignore deliberate stylistic rules in benchmark/
  experiment/test code (E731 lambda assignment, E701/E702 compound
  one-liners) — these are readable, intentional closures and tight
  timing blocks, not bugs.
- Exclude notebooks/, paper/, results/ from linting (demo cell code and
  build artifacts, not the importable library surface).
- Apply ruff autofixes: drop unused imports, split multi-import lines.
- Remove a dead local in test_best_so_far_only_decreases (F841).

`ruff check .` now passes with no errors.
Copilot AI review requested due to automatic review settings June 13, 2026 02:24
@sourcery-ai

sourcery-ai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates Ruff configuration and code style to make ruff check . pass, including excluding non-library directories, ignoring specific stylistic rules in benchmark/experiment code, auto-fixing imports and notebook metadata, and removing one dead local variable in a test.

Flow diagram for updated Ruff lint configuration in CI

flowchart LR
    CI[CI lint job]
    Ruff[ruff check .]
    Src[Library and scripts]
    Excl[Excluded dirs
notebooks, paper, results]
    Rules[Ruff lint rules
ignore E731,E701,E702]
    Status[Lint status
all checks passed]

    CI --> Ruff
    Ruff --> Src
    Ruff -. skips .-> Excl
    Ruff --> Rules
    Ruff --> Status
Loading

File-Level Changes

Change Details Files
Adjust linter configuration to better match project layout and accepted styles so Ruff passes without masking real issues.
  • Extend Ruff exclude list to skip notebooks, paper, and results directories that are not part of the importable library surface.
  • Introduce a dedicated Ruff lint section that ignores E731 and E70x rules, documenting that lambda assignments and compound one-liners are deliberate stylistic choices in benchmark/experiment scripts.
pyproject.toml
Normalize notebooks to current nbformat expectations and clean up their imports to satisfy Ruff.
  • Add stable id fields to all notebook cells so the notebooks conform to modern nbformat requirements.
  • Split multi-import statements into one import per line in code cells (e.g., import os, sys, subprocess → separate lines).
  • Reformat notebook metadata blocks (kernelspec and language_info) as structured, multi-line JSON objects without changing semantics.
notebooks/kaggle_full_benchmark.ipynb
notebooks/gpu_vs_numpy.ipynb
Remove a dead local variable in a benchmark budget test to clear a genuine Ruff F841 finding.
  • Delete the unused wrapped variable assignment in test_best_so_far_only_decreases while leaving the test logic otherwise unchanged.
tests/test_benchmark_budget.py
Apply small Ruff-driven cleanups to scripts, benchmarks, and tests (primarily import hygiene).
  • Drop unused imports and split combined imports into one-per-line across scripts, benchmark modules, and tests, keeping behavior identical.
  • Ensure these modules conform to the new Ruff configuration without altering runtime logic.
scripts/run_ablations.py
scripts/run_feature_selection.py
scripts/run_hpo.py
scripts/run_hpo_real.py
swarmtorch/benchmark/budget.py
swarmtorch/benchmark/gpu_vs_numpy.py
swarmtorch/benchmark/report.py
swarmtorch/experiments/runner.py
tests/test_benchmark_plots_report.py
tests/test_experiments_registry.py
tests/test_hpo_baselines.py
tests/test_vectorized_fitness.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hallelx2, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 43 minutes and 39 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51430539-2a99-42ac-9082-69adca981887

📥 Commits

Reviewing files that changed from the base of the PR and between 86f19a1 and 804915a.

📒 Files selected for processing (17)
  • .github/workflows/ci.yml
  • notebooks/gpu_vs_numpy.ipynb
  • notebooks/kaggle_full_benchmark.ipynb
  • pyproject.toml
  • scripts/run_ablations.py
  • scripts/run_feature_selection.py
  • scripts/run_hpo.py
  • scripts/run_hpo_real.py
  • swarmtorch/benchmark/budget.py
  • swarmtorch/benchmark/gpu_vs_numpy.py
  • swarmtorch/benchmark/report.py
  • swarmtorch/experiments/runner.py
  • tests/test_benchmark_budget.py
  • tests/test_benchmark_plots_report.py
  • tests/test_experiments_registry.py
  • tests/test_hpo_baselines.py
  • tests/test_vectorized_fitness.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch halleluyaholudele/hal-302-ruff-ci-clean

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Instead of globally ignoring E731/E701/E702, consider using per-file-ignores or path-specific sections so that these stylistic relaxations only apply to the benchmark/experiment/test scripts and not to the core library code.
  • The extend-exclude comment only mentions notebooks but the pattern also excludes paper and results; consider updating the comment or narrowing the pattern so it accurately reflects what is being excluded.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of globally ignoring E731/E701/E702, consider using `per-file-ignores` or path-specific sections so that these stylistic relaxations only apply to the benchmark/experiment/test scripts and not to the core library code.
- The `extend-exclude` comment only mentions notebooks but the pattern also excludes `paper` and `results`; consider updating the comment or narrowing the pattern so it accurately reflects what is being excluded.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

conftest.py imports matplotlib for the headless Agg backend, and the
suite exercises the benchmark harness (plots, stats, HPO baselines,
CMA-ES). Installing only .[dev] left those deps missing, so collection
failed with ModuleNotFoundError. Install .[dev,benchmark].

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR restores a green Ruff lint job after the v0.3.0 release by aligning the Ruff configuration with the repo’s existing benchmarking/experiment style and applying straightforward autofixes (unused imports, import splitting, and notebook cell metadata normalization). It’s a maintenance-focused change that should not affect runtime behavior, aside from a small dead-code cleanup in one test.

Changes:

  • Update pyproject.toml Ruff settings to exclude non-library directories and ignore select style-only rules (E701/E702/E731).
  • Remove unused imports across tests/scripts/library modules to satisfy Ruff.
  • Normalize notebooks by adding cell id fields and splitting multi-import statements.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_vectorized_fitness.py Removes unused pytest import.
tests/test_hpo_baselines.py Removes unused torch import.
tests/test_experiments_registry.py Removes unused torch import.
tests/test_benchmark_plots_report.py Removes unused numpy import.
tests/test_benchmark_budget.py Removes an unused local (wrapped) in a test.
swarmtorch/experiments/runner.py Removes unused RunResult import.
swarmtorch/benchmark/report.py Removes unused Any import.
swarmtorch/benchmark/gpu_vs_numpy.py Removes unused SYNTHETIC_FUNCTIONS import.
swarmtorch/benchmark/budget.py Removes unused Any import.
scripts/run_hpo.py Removes unused BaselineHPO import.
scripts/run_hpo_real.py Removes unused Any import.
scripts/run_feature_selection.py Removes unused Any import.
scripts/run_ablations.py Removes unused PAPER_ALGORITHMS import.
pyproject.toml Adjusts Ruff lint configuration (excludes + ignore list).
notebooks/kaggle_full_benchmark.ipynb Adds cell IDs and splits multi-imports.
notebooks/gpu_vs_numpy.ipynb Adds cell IDs and splits multi-imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hallelx2 hallelx2 merged commit 10a479a into master Jun 13, 2026
6 checks passed
@hallelx2 hallelx2 deleted the halleluyaholudele/hal-302-ruff-ci-clean branch June 13, 2026 02:30
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.

2 participants