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 recursive option to runner, optimize imports. #4

Closed

Conversation

ayasyrev
Copy link
Contributor

@ayasyrev ayasyrev commented Oct 28, 2024

Add recursive option to runner - search for images in folder with rglob.
Need to add -R option to run_all.sh script, but not sure how to do it.

Summary by Sourcery

Add a recursive option to the benchmark runner to enable searching for images in subdirectories and optimize import statements for improved code organization.

New Features:

  • Introduce a recursive option in the benchmark runner to allow searching for images in subdirectories.

Enhancements:

  • Optimize import statements in the benchmark runner script.

Copy link

sourcery-ai bot commented Oct 28, 2024

Reviewer's Guide by Sourcery

The PR adds a recursive directory traversal option to the benchmark runner, allowing it to search for images in subdirectories. This is implemented by adding a new -R/--recursive flag to the CLI and modifying the image loading logic to use rglob instead of glob when the recursive option is enabled.

Sequence diagram for loading images with recursive option

sequenceDiagram
    participant User
    participant CLI
    participant BenchmarkRunner
    participant FileSystem

    User->>CLI: Run with -R option
    CLI->>BenchmarkRunner: Initialize with recursive=True
    BenchmarkRunner->>FileSystem: rglob("*.*")
    FileSystem-->>BenchmarkRunner: Return image paths
    BenchmarkRunner->>CLI: Load images
    CLI-->>User: Display progress
Loading

Updated class diagram for BenchmarkRunner

classDiagram
    class BenchmarkRunner {
        -library: str
        -data_dir: Path
        -recursive: bool
        -num_images: int
        -num_runs: int
        -max_warmup_iterations: int
        -warmup_window: int
        -warmup_threshold: float
        +__init__(library: str, data_dir: Path, recursive: bool = False, num_images: int = 1000, num_runs: int = 5, max_warmup_iterations: int = 1000, warmup_window: int = 5, warmup_threshold: float = 0.05)
        +_get_implementation() Any
        +load_images() list[Any]
    }
    note for BenchmarkRunner "Added 'recursive' attribute and modified 'load_images' method to support recursive image loading."
Loading

File-Level Changes

Change Details Files
Added recursive directory traversal option to the benchmark runner
  • Added recursive boolean parameter to BenchmarkRunner class constructor
  • Modified load_images method to use rglob when recursive flag is True
  • Added -R/--recursive command line argument to main function
benchmark/runner.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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

@ternaus ternaus closed this Dec 21, 2024
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