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

add codeflash GHA ⚡️ #2380

Merged
merged 3 commits into from
Mar 6, 2025
Merged

add codeflash GHA ⚡️ #2380

merged 3 commits into from
Mar 6, 2025

Conversation

KRRT7
Copy link
Contributor

@KRRT7 KRRT7 commented Mar 4, 2025

Summary by Sourcery

Adds a GitHub Actions workflow to run Codeflash on pull requests that modify files in the albumentations directory.
CI:

  • Adds a new CI workflow to run Codeflash on pull requests.
  • Configures the workflow to only run when code within the albumentations module is modified.
  • Sets up Python and installs dependencies, including development dependencies.
  • Runs Codeflash to optimize new Python code in the pull request.

Copy link
Contributor

sourcery-ai bot commented Mar 4, 2025

Reviewer's Guide by Sourcery

This pull request adds a GitHub Actions workflow to run Codeflash on pull requests, adds a sorting function to functional.py, and adds uv to the development dependencies. The workflow is triggered on pull requests that modify files in the albumentations/** path. The sorting function implements a bubble sort algorithm and prints the sorted array to standard output.

Sequence diagram for Codeflash workflow

sequenceDiagram
    participant GH as GitHub
    participant Runner
    participant Codeflash

    GH->>Runner: Pull Request to albumentations/**
    Runner->>Runner: Checkout code
    Runner->>Runner: Set up Python
    Runner->>Runner: Install uv
    Runner->>Runner: Install Dependencies
    Runner->>Runner: Install Dev dependencies
    Runner->>Codeflash: Run Codeflash
    Codeflash-->>Runner: Optimization suggestions
    Runner-->>GH: Create commit with suggestions
Loading

Class diagram for the new sorter function

classDiagram
    class functional {
      +convolve()
      +separable_convolve()
      +sorter(arr)
    }
    note for functional "Adds a bubble sort algorithm to the functional class"
Loading

File-Level Changes

Change Details Files
Added a GitHub Actions workflow to run Codeflash on pull requests.
  • Created a new workflow file codeflash.yml in .github/workflows/.
  • Configured the workflow to trigger on pull requests that modify files in the albumentations/** path.
  • Added a concurrency group to cancel in-progress runs when new pushes are made to the PR.
  • The workflow checks out the code, sets up Python, installs dependencies using uv, and runs Codeflash.
  • The workflow uses a secret CODEFLASH_API_KEY and the pull request number from the GitHub event context.
.github/workflows/codeflash.yml
Added a sorting function to functional.py.
  • Added a function sorter that implements a bubble sort algorithm.
  • The function iterates through the input array and swaps adjacent elements if they are in the wrong order.
  • The function prints "codeflash" to standard output.
  • The function prints the sorted array to standard output.
albumentations/augmentations/functional.py
Added uv to the development dependencies.
  • Added uv to the requirements-dev.txt file.
requirements-dev.txt

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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
Contributor

@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 @KRRT7 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a test case for the new sorter function to ensure it functions correctly.
  • It's unusual to add a sorting function to functional.py; consider if it belongs in a more specific module.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@KRRT7 KRRT7 changed the title test GHA add codeflash GHA ⚡️ Mar 4, 2025
@KRRT7
Copy link
Contributor Author

KRRT7 commented Mar 4, 2025

Hi @plashchynski the GHA is good to go, you will have to create an API key @ https://app.codeflash.ai/app/apikeys and then set the key as an action secret.

@ternaus
Copy link
Collaborator

ternaus commented Mar 5, 2025

@KRRT7 Will this GHA propose changes or will modify files?

@KRRT7
Copy link
Contributor Author

KRRT7 commented Mar 5, 2025

@KRRT7 Will this GHA propose changes or will modify files?

it will propose changes into the PRs themselves if any optimizations are found

@KRRT7 KRRT7 requested a review from ternaus March 6, 2025 23:20
@ternaus ternaus merged commit 463cc99 into albumentations-team:main Mar 6, 2025
14 checks passed
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