Skip to content

Conversation

@atong01
Copy link
Owner

@atong01 atong01 commented Sep 9, 2025

Github actions for this repo have not been updated in a while. This PR seeks to update to a more modern workflow.

  • Updates package versions
  • Switches code formatting to new stack built on ruff, gitleaks, prettier
  • Fixes formatting things caught by ruff
  • Should preserve functionality
  • Adds one function based on scipy OT calculation

Summary by Sourcery

Modernize the repository’s code quality and CI tooling by upgrading pre-commit hooks and GitHub Actions workflows, adopting a new formatting stack (ruff, gitleaks, prettier), and applying automated fixes and cleanup across the codebase.

Enhancements:

  • Replace legacy formatters (black, isort, flake8, bandit, docformatter, mdformat) with ruff for linting/formatting, gitleaks for secret detection, and prettier for YAML/Markdown
  • Upgrade pre-commit-config to use newer hook versions and configure ruff.lint and ruff.isort settings

CI:

  • Update GitHub Actions code-quality workflow: bump actions/checkout to v5, setup-python to v6, pre-commit action to v3, target Python 3.13, and add pull_request triggers

Documentation:

  • Normalize README markdown styling for consistency

Tests:

  • Apply formatting cleanup in test files (remove unused imports, fix trailing commas)

Chores:

  • Apply automated formatting fixes across codebase: tidy docstrings, remove dead code and unused variables, unify import styles and indentation

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 9, 2025

Reviewer's Guide

This PR modernizes the repository’s CI and formatting infrastructure by upgrading GitHub Actions workflows, replacing legacy pre-commit hooks and lint settings with a new Ruff-based stack, and applying the resulting automatic formatting fixes across the codebase.

Entity relationship diagram for updated pre-commit configuration

erDiagram
  PRE_COMMIT_CONFIG ||--|{ REPO : contains
  REPO {
    string url
    string rev
    string[] hooks
  }
  HOOK {
    string id
    string[] args
    string[] exclude_types
  }
  PRE_COMMIT_CONFIG {
    REPO[] repos
  }
  REPO ||--|{ HOOK : has

  PRE_COMMIT_CONFIG ||--|{ RUFF_CONFIG : uses
  RUFF_CONFIG {
    int line_length
    string[] ignore
    string[] select
    string[] known_first_party
    string[] known_third_party
    string[] per_file_ignores
  }
Loading

Class diagram for updated ConditionalFlowMatcher and subclasses

classDiagram
  class ConditionalFlowMatcher {
    +float sigma
    +__init__(sigma: Union[float, int] = 0.0)
    +compute_lambda(t)
  }
  class ExactOptimalTransportConditionalFlowMatcher {
    +OTPlanSampler ot_sampler
    +__init__(sigma: Union[float, int] = 0.0)
    +sample_location_and_conditional_flow()
  }
  class TargetConditionalFlowMatcher {
    +compute_mu_t()
    +compute_sigma_t()
    +compute_conditional_flow()
  }
  class SchrodingerBridgeConditionalFlowMatcher {
    +__init__(sigma: Union[float, int] = 1.0, ot_method="exact")
    +compute_sigma_t()
    +compute_conditional_flow()
    +sample_location_and_conditional_flow()
  }
  class VariancePreservingConditionalFlowMatcher {
    +compute_mu_t()
    +compute_conditional_flow()
  }
  ConditionalFlowMatcher <|-- ExactOptimalTransportConditionalFlowMatcher
  ConditionalFlowMatcher <|-- TargetConditionalFlowMatcher
  ConditionalFlowMatcher <|-- SchrodingerBridgeConditionalFlowMatcher
  ConditionalFlowMatcher <|-- VariancePreservingConditionalFlowMatcher
Loading

File-Level Changes

Change Details Files
GitHub Actions workflow updated to latest versions and triggers
  • Bump actions/checkout to v5 and actions/setup-python to v6
  • Upgrade default Python version from 3.10 to 3.13
  • Add pull_request trigger for main and release/* branches
.github/workflows/code-quality-main.yaml
Pre-commit config migrated to Ruff, Gitleaks, and Prettier stack
  • Remove Black, isort, flake8, bandit, and docformatter hooks
  • Add ruff (with --fix and ruff-format), gitleaks, and prettier hooks
  • Update hook revisions for pre-commit-hooks and pyupgrade
.pre-commit-config.yaml
Lint settings shifted from Flake8 to Ruff in pyproject.toml
  • Replace [tool.flake8] section with [tool.ruff] and [tool.ruff.lint] settings
  • Define per-file-ignores and isort integration under ruff.lint
  • Remove bandit and isort sections
pyproject.toml
Automatic formatting fixes applied throughout .py files
  • Rewrap and indent docstrings consistently
  • Add trailing commas on multi-line calls and remove unused imports
  • Simplify lambdas to list comprehensions and trim blank lines
torchcfm/**/*.py
runner/src/**/*.py
examples/**/*.py
tests/**/*.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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Double-check that switching the GitHub action to Python 3.13 is supported by all your dependencies and runners, as 3.13 may not yet be stable in some environments.
  • Since bandit was removed in favor of gitleaks, consider re-adding a dedicated Python security linter or enabling ruff’s security plugins to retain deeper vulnerability scanning.
  • Verify that renaming the workflow to code-quality.yaml and adding pull_request triggers on main and release/* still aligns with your CI/CD expectations and fires correctly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Double-check that switching the GitHub action to Python 3.13 is supported by all your dependencies and runners, as 3.13 may not yet be stable in some environments.
- Since bandit was removed in favor of gitleaks, consider re-adding a dedicated Python security linter or enabling ruff’s security plugins to retain deeper vulnerability scanning.
- Verify that renaming the workflow to code-quality.yaml and adding pull_request triggers on main and release/* still aligns with your CI/CD expectations and fires correctly.

## Individual Comments

### Comment 1
<location> `tests/test_models.py:8` </location>
<code_context>


 def test_initialize_models():
-    model = UNetModel(
+    UNetModel(
         dim=(1, 28, 28),
         num_channels=32,
</code_context>

<issue_to_address>
Missing assertions in model initialization test.

Add assertions to verify correct model instantiation and expected key properties, such as output shapes and parameter counts.
</issue_to_address>

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.

from torchcfm.models import MLP
from torchcfm.models.unet import UNetModel


Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Missing assertions in model initialization test.

Add assertions to verify correct model instantiation and expected key properties, such as output shapes and parameter counts.

plt.plot(path[:, 0], path[:, 1])
plt.show()

def factory(name, args):
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): The first argument to instance methods should be self (instance-method-first-arg-name)

@atong01 atong01 merged commit 66b236b into main Sep 9, 2025
17 of 18 checks passed
@atong01 atong01 deleted the update-actions branch September 9, 2025 13:10
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