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

Feature/refactor standard graph plots #93

Merged
merged 8 commits into from
Feb 12, 2025

Conversation

mayurkmmt
Copy link
Collaborator

@mayurkmmt mayurkmmt commented Feb 12, 2025

User description

Feature/refactor standard graph plots


PR Type

Enhancement, Tests, Dependencies


Description

  • Refactored plotting modules into separate files for better modularity.

    • Added index.py, time.py, and waterfall.py for specific plot types.
  • Enhanced testing coverage for all plotting modules.

    • Added unit tests for index, time, and waterfall plots.
  • Replaced Poetry with UV for dependency management.

    • Updated workflows and pyproject.toml to reflect this change.
  • Updated documentation to reflect new module structure.


Changes walkthrough 📝

Relevant files
Enhancement
4 files
index.py
Added module for index plot functionality                               
+283/-0 
time.py
Added module for timeline plot functionality                         
+148/-0 
waterfall.py
Added module for waterfall chart functionality                     
+182/-0 
graph_utils.py
Enhanced graph utility functions for legend visibility     
+10/-1   
Tests
3 files
test_index.py
Added unit tests for index plot module                                     
+304/-0 
test_time.py
Added unit tests for timeline plot module                               
+93/-0   
test_waterfall.py
Added unit tests for waterfall plot module                             
+106/-0 
Configuration changes
3 files
gh-page.yml
Updated workflow to use UV for dependency management         
+3/-4     
release.yml
Updated release workflow to use UV for versioning               
+5/-6     
test.yml
Updated test workflow to use UV for dependency management
+3/-4     
Documentation
1 files
analysis_modules.md
Updated documentation to reflect new plotting modules       
+6/-6     
Dependencies
1 files
pyproject.toml
Migrated from Poetry to UV for dependency management         
+45/-37 
Additional files
2 files
standard_graphs.py +0/-444 
test_standard_graphs.py +0/-221 

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Summary by CodeRabbit

    • New Features
      • Introduced index plots, timeline visualizations, and waterfall charts for enhanced data analysis.
    • Documentation
      • Updated examples and usage instructions to reflect changes in plotting methods and module structure.
    • Chores
      • Streamlined build and deployment workflows with updated dependency management and project configuration.
    • Style
      • Added customizable options for graph styling, including toggling the legend display.
    • Bug Fixes
      • Improved error handling in plotting functions to manage invalid inputs and conditions.
    • Tests
      • Added comprehensive test suites for new plotting functionalities, ensuring robustness and correctness.
      • Introduced tests for the time_plot and waterfall_plot functions, covering various scenarios and edge cases.
      • Enhanced test coverage for the index_plot functionality, validating behavior under multiple conditions.

    Copy link

    coderabbitai bot commented Feb 12, 2025

    Walkthrough

    The changes replace the Poetry-based dependency management in GitHub workflows with the uv package. The pyproject.toml file has been overhauled to transition from Poetry to Hatchling with a more structured dependency layout. Import paths in documentation have been updated to reflect a new plotting module location. New modules for index, time, and waterfall plots have been introduced along with corresponding tests, while the legacy standard graphs module and its tests were removed. Additionally, the graph styling function now supports an optional parameter to control legend display.

    Changes

    File(s) Change Summary
    .github/workflows/gh-page.yml, .github/workflows/release.yml, .github/workflows/test.yml Replaced steps for Poetry installation/configuration with installation of uv (v0.5.30) and updated commands to use uv sync for dependency management and version retrieval.
    docs/analysis_modules.md Updated import paths for plotting functions from pyretailscience.standard_graphs to pyretailscience.plots.
    pyproject.toml Restructured configuration: shifted from [tool.poetry] to [project], updated authors format, added requires-python, reorganized dependencies into groups, and switched build system from Poetry to Hatchling.
    pyretailscience/plots/index.py, pyretailscience/plots/time.py, pyretailscience/plots/waterfall.py Added new plotting modules with functions for index, time, and waterfall plots, including helper methods and formatting options.
    pyretailscience/standard_graphs.py Removed the entire module containing legacy standard graph functions.
    pyretailscience/style/graph_utils.py Updated the standard_graph_styles function signature to include a new show_legend parameter.
    tests/plots/test_index.py, tests/plots/test_time.py, tests/plots/test_waterfall.py Introduced new test suites covering behavior and error handling for the index, time, and waterfall plotting functionalities.
    tests/test_standard_graphs.py Removed tests for the now-deleted standard_graphs module.

    Suggested labels

    enhancement, documentation, Tests

    Suggested reviewers

    • murray-ds

    Poem

    In a land of code I hop along,
    Leaving old Poetry behind in song.
    Now uv leads the way so bright,
    With Hatchling guiding through the night.
    Plots now bloom—time, index, waterfall,
    Hop along with me, let's celebrate it all! 🐰✨


    📜 Recent review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 021d2ff and 577a21f.

    📒 Files selected for processing (4)
    • .github/workflows/gh-page.yml (1 hunks)
    • .github/workflows/release.yml (2 hunks)
    • .github/workflows/test.yml (1 hunks)
    • .pre-commit-config.yaml (1 hunks)
    🚧 Files skipped from review as they are similar to previous changes (1)
    • .pre-commit-config.yaml
    🔇 Additional comments (5)
    .github/workflows/test.yml (1)

    22-26: Update UV version and add error handling.

    Based on the latest information:

    1. UV version 0.5.30 might be unreleased or invalid
    2. Missing error handling for UV commands
    3. Missing UV environment configuration

    Apply this diff to address these issues:

    -      - name: Install UV
    +      - name: Install and Configure UV
           run: |
             pip install --upgrade pip
    -        pip install uv==0.5.30
    +        pip install uv==0.5.28
    +        export UV_VENV_CREATE=false
    -        uv sync
    +        uv sync || exit 1
    .github/workflows/gh-page.yml (2)

    33-40: Update UV version and add error handling.

    The same issues with UV configuration are present in this workflow:

    1. UV version 0.5.30 might be unreleased or invalid
    2. Missing error handling for UV commands
    3. Missing UV environment configuration

    Apply this diff to address these issues:

    -      - name: Install uv Package
    +      - name: Install and Configure UV
           run: |
             pip install --upgrade pip
    -        pip install uv==0.5.30
    +        pip install uv==0.5.28
    +        export UV_VENV_CREATE=false

    40-40: Add error handling for UV sync command.

    Apply this diff:

    -        run: uv sync
    +        run: uv sync || exit 1
    .github/workflows/release.yml (2)

    37-44: Update UV version and add error handling.

    The same issues with UV configuration are present in this workflow:

    1. UV version 0.5.30 might be unreleased or invalid
    2. Missing error handling for UV commands
    3. Missing UV environment configuration

    Apply this diff to address these issues:

    -      - name: Install uv Package
    +      - name: Install and Configure UV
           run: |
             pip install --upgrade pip
             pip install build
    -        pip install uv==0.5.30
    +        pip install uv==0.5.28
    +        export UV_VENV_CREATE=false
    -        uv sync
    -        uv version
    +        uv sync || exit 1
    +        uv version || exit 1

    60-60: Add error handling for version retrieval.

    The version retrieval command should handle potential failures.

    Apply this diff:

    -          VERSION=$(uv version)
    +          VERSION=$(uv version) || exit 1

    Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

    ❤️ Share
    🪧 Tips

    Chat

    There are 3 ways to chat with CodeRabbit:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
      • I pushed a fix in commit <commit_id>, please review it.
      • Generate unit testing code for this file.
      • Open a follow-up GitHub issue for this discussion.
    • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
      • @coderabbitai generate unit testing code for this file.
      • @coderabbitai modularize this function.
    • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
      • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
      • @coderabbitai read src/utils.ts and generate unit testing code.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
      • @coderabbitai help me debug CodeRabbit configuration file.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (Invoked using PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai full review to do a full review from scratch and review all the files again.
    • @coderabbitai summary to regenerate the summary of the PR.
    • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
    • @coderabbitai help to get help.

    Other keywords and placeholders

    • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
    • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
    • Add @coderabbitai anywhere in the PR title to generate the title automatically.

    CodeRabbit Configuration File (.coderabbit.yaml)

    • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
    • Please see the configuration documentation for more information.
    • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Complexity

    The plot() function has high cyclomatic complexity and many parameters. Consider breaking it down into smaller functions for better maintainability.

    def plot(  # noqa: C901, PLR0913 (ignore complexity and line length)
        df: pd.DataFrame,
        df_index_filter: list[bool],
        value_col: str,
        group_col: str,
        agg_func: str = "sum",
        series_col: str | None = None,
        title: str | None = None,
        x_label: str = "Index",
        y_label: str | None = None,
        legend_title: str | None = None,
        highlight_range: Literal["default"] | tuple[float, float] | None = "default",
        sort_by: Literal["group", "value"] | None = "group",
        sort_order: Literal["ascending", "descending"] = "ascending",
        ax: Axes | None = None,
        source_text: str | None = None,
        exclude_groups: list[any] | None = None,
        include_only_groups: list[any] | None = None,
        **kwargs: dict[str, any],
    ) -> SubplotBase:
    TODO Comment

    There is a TODO comment about simplifying color range that should be addressed before merging.

    # TODO: Consider simplifying this by reducing the color range in the get_linear_cmap function.
    COLORMAP_MIN = 0.25
    COLORMAP_MAX = 0.75

    Copy link
    Contributor

    qodo-merge-pro bot commented Feb 12, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Standardize function return type

    The format_data_labels function returns different types (pd.Series vs list)
    depending on the label_format parameter, which could lead to type
    inconsistencies. Standardize the return type to always be a list.

    pyretailscience/plots/waterfall.py [176-182]

     if label_format == "absolute":
    -    return amounts.apply(lambda x: gu.human_format(x, decimals=decimals + 1))
    +    return amounts.apply(lambda x: gu.human_format(x, decimals=decimals + 1)).tolist()
     
     if label_format == "percentage":
    -    return amounts.apply(lambda x: f"{x / total_change:.0%}")
    +    return amounts.apply(lambda x: f"{x / total_change:.0%}").tolist()
     
     return [f"{gu.human_format(x, decimals=decimals + 1)} ({x / total_change:.0%})" for x in amounts]
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: This suggestion improves code consistency and prevents potential type-related issues by ensuring the function always returns a list, making the code more maintainable and less error-prone.

    Medium
    Add package installation verification

    Add error handling and version verification after installing uv package to
    ensure the correct version is installed and working properly.

    .github/workflows/gh-page.yml [33-36]

     - name: Install uv Package
       run: |
         pip install --upgrade pip
         pip install uv==0.5.30
    +    uv --version || exit 1
    +    if ! uv --version | grep -q "0.5.30"; then
    +      echo "Incorrect uv version installed"
    +      exit 1
    +    fi
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion adds important version verification and error handling for the uv package installation, which could prevent silent failures and ensure the correct version is being used in the CI pipeline.

    Medium
    Add dependency installation error handling

    Add error handling for the uv sync command to ensure dependencies are installed
    correctly and fail the workflow if installation fails.

    .github/workflows/gh-page.yml [37-38]

     - name: Install Dependencies
    -  run: uv sync
    +  run: |
    +    uv sync || {
    +      echo "Failed to sync dependencies"
    +      exit 1
    +    }
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    __

    Why: Adding explicit error handling for the 'uv sync' command improves the workflow's reliability by ensuring dependency installation failures are caught and reported clearly, rather than potentially continuing with missing dependencies.

    Low
    General
    Remove or implement TODO comment

    The COLORMAP_MIN and COLORMAP_MAX constants are marked as TODO for
    simplification but are still used in production code. Either implement the
    simplification or remove the TODO comment to avoid confusion.

    pyretailscience/plots/time.py [47-50]

    -# TODO: Consider simplifying this by reducing the color range in the get_linear_cmap function.
     COLORMAP_MIN = 0.25
     COLORMAP_MAX = 0.75

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 3

    __

    Why: While this suggestion addresses code cleanliness by removing a TODO comment or implementing the suggested change, it has relatively low impact on functionality since the code works correctly as is.

    Low

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

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

    Actionable comments posted: 1

    🧹 Nitpick comments (8)
    pyretailscience/plots/index.py (1)

    58-59: Validate aggregator string usage.

    Currently, the agg_func parameter is taken as a string (e.g., "sum") without verifying if it is recognized by Pandas. Consider validating or handling invalid aggregator inputs to prevent runtime errors.

    tests/plots/test_time.py (1)

    24-24: Remove parentheses in @pytest.fixture.

    According to the style hint (PT001), use @pytest.fixture instead of @pytest.fixture().

    -    @pytest.fixture()
    +    @pytest.fixture
    🧰 Tools
    🪛 Ruff (0.8.2)

    24-24: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)

    tests/plots/test_waterfall.py (2)

    15-15: Remove parentheses in @pytest.fixture.

    According to the style hint (PT001), use @pytest.fixture instead of @pytest.fixture().

    -    @pytest.fixture()
    +    @pytest.fixture
    🧰 Tools
    🪛 Ruff (0.8.2)

    15-15: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)


    54-54: Cleanup function name to remove duplication.

    The method name test_plot_colors_assigned_correctly_replicated_replicated appears to contain a duplicated word. Consider renaming it to something like test_plot_colors_assigned_correctly.

    pyretailscience/plots/time.py (2)

    46-48: Address the TODO comment about color range.

    The TODO comment suggests simplifying the color range in the get_linear_cmap function.

    Would you like me to help implement this simplification or create an issue to track this task?


    51-148: Consider enhancing error handling and input validation.

    The plot function could benefit from additional error handling:

    1. Validate that value_col exists in the DataFrame
    2. Validate that period is a valid time period string
    3. Validate that agg_func is a valid aggregation function

    Here's a suggested implementation:

    def plot(
        df: pd.DataFrame,
        value_col: str,
        period: str | BaseOffset = "D",
        agg_func: str = "sum",
        group_col: str | None = None,
        ...
    ) -> SubplotBase:
    +    if value_col not in df.columns:
    +        raise ValueError(f"Column '{value_col}' not found in DataFrame")
    +
    +    if isinstance(period, str) and period not in ["D", "W", "M", "Q", "Y"]:
    +        raise ValueError(f"Invalid period '{period}'. Must be one of: D, W, M, Q, Y")
    +
    +    if agg_func not in ["sum", "mean", "count", "min", "max"]:
    +        raise ValueError(f"Invalid aggregation function '{agg_func}'")
    +
    +    if group_col is not None and group_col not in df.columns:
    +        raise ValueError(f"Column '{group_col}' not found in DataFrame")
    
        df["transaction_period"] = df[get_option("column.transaction_date")].dt.to_period(
            period,
        )
        ...
    pyretailscience/plots/waterfall.py (1)

    83-94: Consider improving error message for data label format validation.

    The error message could be more descriptive by listing the valid options.

    -            "data_label_format must be either 'absolute', 'percentage', 'both', or None.",
    +            "data_label_format must be one of: 'absolute', 'percentage', 'both', or None",
    tests/plots/test_index.py (1)

    134-134: Remove unnecessary parentheses in pytest.fixture decorators.

    Static analysis suggests removing empty parentheses from pytest.fixture decorators.

    -@pytest.fixture()
    +@pytest.fixture

    Also applies to: 145-145

    🧰 Tools
    🪛 Ruff (0.8.2)

    134-134: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)

    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 2eab9a7 and de8b82b.

    ⛔ Files ignored due to path filters (2)
    • poetry.lock is excluded by !**/*.lock
    • uv.lock is excluded by !**/*.lock
    📒 Files selected for processing (14)
    • .github/workflows/gh-page.yml (1 hunks)
    • .github/workflows/release.yml (2 hunks)
    • .github/workflows/test.yml (1 hunks)
    • docs/analysis_modules.md (4 hunks)
    • pyproject.toml (1 hunks)
    • pyretailscience/plots/index.py (1 hunks)
    • pyretailscience/plots/time.py (1 hunks)
    • pyretailscience/plots/waterfall.py (1 hunks)
    • pyretailscience/standard_graphs.py (0 hunks)
    • pyretailscience/style/graph_utils.py (3 hunks)
    • tests/plots/test_index.py (1 hunks)
    • tests/plots/test_time.py (1 hunks)
    • tests/plots/test_waterfall.py (1 hunks)
    • tests/test_standard_graphs.py (0 hunks)
    💤 Files with no reviewable changes (2)
    • tests/test_standard_graphs.py
    • pyretailscience/standard_graphs.py
    🧰 Additional context used
    🪛 Ruff (0.8.2)
    tests/plots/test_time.py

    24-24: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)

    tests/plots/test_waterfall.py

    15-15: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)

    tests/plots/test_index.py

    134-134: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)


    145-145: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)

    🔇 Additional comments (18)
    pyretailscience/plots/index.py (1)

    264-265: Good validation on df_index_filter.

    Raising an error when the filter is all True or all False helps avoid misleading calculations. This check is clear and prevents unintended edge cases.

    tests/plots/test_time.py (1)

    1-23: Test coverage looks solid.

    All core scenarios (e.g., invalid period, group columns, source text) are covered comprehensively.

    pyretailscience/plots/time.py (1)

    1-34: LGTM! Well-structured documentation.

    The module's documentation is comprehensive and well-organized, covering features, use cases, limitations, and functionality details. This enhances code maintainability and usability.

    pyretailscience/plots/waterfall.py (1)

    1-28: LGTM! Well-structured documentation.

    The module's documentation is comprehensive and well-organized, providing clear explanations of features, use cases, and functionality.

    tests/plots/test_index.py (2)

    13-129: LGTM! Comprehensive test coverage for get_indexes().

    The test suite thoroughly covers various scenarios including single column, two columns, offset parameter, aggregation functions, and error cases.


    131-305: LGTM! Comprehensive test coverage for plot().

    The test class provides thorough coverage of the plot functionality, including:

    • Default parameters
    • Custom titles and labels
    • Highlight ranges
    • Group filters
    • Error handling
    • Source text
    • Legend behavior
    🧰 Tools
    🪛 Ruff (0.8.2)

    134-134: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)


    145-145: Use @pytest.fixture over @pytest.fixture()

    Remove parentheses

    (PT001)

    pyretailscience/style/graph_utils.py (2)

    178-178: LGTM! Well-documented parameter addition.

    The new show_legend parameter is properly documented with a clear description of its purpose.

    Also applies to: 193-193


    228-235: LGTM! Clean implementation of legend control.

    The implementation cleanly handles the legend display control by returning early when show_legend is False.

    .github/workflows/gh-page.yml (1)

    33-38: LGTM! Consistent with other workflow changes.

    The workflow has been updated to use uv instead of Poetry, maintaining consistency with other workflow files.

    .github/workflows/release.yml (2)

    37-43: LGTM! Consistent with other workflow changes.

    The workflow has been updated to use uv instead of Poetry, maintaining consistency with other workflow files.


    59-59: LGTM! Version retrieval updated for uv.

    The version retrieval command has been correctly updated to use uv's version command.

    pyproject.toml (4)

    1-23: LGTM! Well-structured project metadata and dependencies.

    The project configuration has been updated to use the modern [project] format with explicit version constraints for dependencies.


    25-43: LGTM! Well-organized dependency groups.

    Dependencies are logically grouped into dev, examples, and docs categories with explicit version constraints.


    45-50: LGTM! Proper uv configuration.

    The uv configuration correctly includes all dependency groups by default.


    52-54: LGTM! Updated build system.

    The build system has been correctly updated to use Hatchling.

    docs/analysis_modules.md (3)

    171-171: LGTM! Updated import path for waterfall plot.

    The import path has been correctly updated to use the new module structure.

    Also applies to: 176-176


    215-215: LGTM! Updated import path for index plot.

    The import path has been correctly updated to use the new module structure.

    Also applies to: 217-217


    256-256: LGTM! Updated import path for time plot.

    The import path has been correctly updated to use the new module structure.

    Also applies to: 272-272

    Comment on lines 22 to 26
    - name: Install uv Package
    run: |
    pip install --upgrade pip
    pip install poetry==1.3.2
    poetry config virtualenvs.create false
    poetry install --no-interaction --with dev
    pip install uv==0.5.30
    uv sync
    Copy link

    Choose a reason for hiding this comment

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

    💡 Verification agent

    🧩 Analysis chain

    Verify the uv package version.

    The workflow has been updated to use uv instead of Poetry, which is a good choice for faster dependency resolution. However, let's verify if version 0.5.30 is the latest stable version.


    🌐 Web query:

    What is the latest stable version of uv?
    

    💡 Result:

    The latest stable version of uv as of February 12, 2025 is 0.[7]. This information is confirmed by multiple sources:

    • Homebrew lists uv version stable as version stable [7]
    • PyPI also shows uv version stable [2]
    • The Snapcraft store lists astral-uv with latest/stable updated on January [9]

    For installation:

    # Install via Homebrew
    brew install uv
    
    # Install via Snap
    sudo snap install astral-uv --classic
    
    # Install via PyPI
    pip install uv==

    Citations:


    Outdated uv Package Version Detected

    The workflow file currently installs uv 0.5.30. However, based on our research, the latest stable version of uv as of February 2025 is 0.7. Please update the version accordingly.

    • Update uv package version in .github/workflows/test.yml from 0.5.30 to 0.7.

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

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

    Actionable comments posted: 2

    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between de8b82b and 76146ee.

    📒 Files selected for processing (3)
    • .github/workflows/gh-page.yml (1 hunks)
    • .github/workflows/release.yml (2 hunks)
    • .github/workflows/test.yml (1 hunks)
    🚧 Files skipped from review as they are similar to previous changes (2)
    • .github/workflows/gh-page.yml
    • .github/workflows/test.yml

    Comment on lines 37 to 44
    - name: Install uv Package
    run: |
    pip install --upgrade pip
    pip install build
    pip install poetry==1.3.2
    poetry config virtualenvs.create false
    poetry install --no-interaction --with dev
    poetry version ${{ inputs.release }}
    pip install uv==0.5.30
    export UV_VENV_CREATE=false
    uv sync
    uv version
    Copy link

    Choose a reason for hiding this comment

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

    💡 Verification agent

    🧩 Analysis chain

    Verify UV package version and configuration.

    The UV package is pinned to version 0.5.30. Since this is a relatively new package manager, we should verify if this is the latest stable version and if there are any known issues.

    Additionally, consider adding error handling for the UV commands:

     pip install uv==0.5.30
     export UV_VENV_CREATE=false
    -uv sync
    -uv version
    +uv sync || exit 1
    +uv version || exit 1

    🌐 Web query:

    What is the latest stable version of UV package manager? Are there any known issues with version 0.5.30?
    

    💡 Result:

    Based on the search results:

    The latest stable version of UV mentioned across sources is 0.5.28, released on GitHub[4]. This version includes bug fixes for virtual environment discovery, SSL handling in Git operations, and tar unpacking[4].

    There's no mention of version 0.5.30 in any provided sources - this version either:

    1. Doesn't exist yet as of February 2025
    2. May be an unreleased/development version
    3. Could be a typo in the query

    For recent known issues (as of latest documented releases):

    - Installation challenges on ARMv7 Linux systems [4]
    - Occasional permission errors during cache writes on Windows [4]
    - Python version management conflicts when mixing system and managed interpreters [2][4]
    - Ephemeral environment cleanup issues in CI/CD pipelines [4]
    

    Developers should consult UV's GitHub releases page for real-time updates[4]. The project maintains an active issue tracker addressing reported bugs[9].

    Citations:


    UV Package Version Issue & Error Handling Improvements

    • The web query confirms that the latest stable version is 0.5.28, and using uv==0.5.30 may reference an unreleased or mistyped version.
    • Consider pinning UV to version 0.5.28.
    • Additionally, add error handling for the uv sync and uv version commands (e.g., using || exit 1) to catch failures during workflow execution.
    📝 Committable suggestion

    ‼️ IMPORTANT
    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    Suggested change
    - name: Install uv Package
    run: |
    pip install --upgrade pip
    pip install build
    pip install poetry==1.3.2
    poetry config virtualenvs.create false
    poetry install --no-interaction --with dev
    poetry version ${{ inputs.release }}
    pip install uv==0.5.30
    export UV_VENV_CREATE=false
    uv sync
    uv version
    - name: Install uv Package
    run: |
    pip install --upgrade pip
    pip install build
    pip install uv==0.5.30
    export UV_VENV_CREATE=false
    uv sync || exit 1
    uv version || exit 1

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

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

    Actionable comments posted: 0

    🧹 Nitpick comments (1)
    .pre-commit-config.yaml (1)

    22-22: LGTM! Consider pinning the pytest version.

    The integration with UV aligns well with the project's transition from Poetry. However, to ensure consistent test execution across all environments, consider pinning the pytest version.

    -        entry: uv run pytest --cov=pyretailscience --cov-report=xml --cov-branch tests
    +        entry: uv run pytest==8.0.0 --cov=pyretailscience --cov-report=xml --cov-branch tests

    Let's verify the latest stable version of pytest:

    ✅ Verification successful

    🌐 Web query:

    What is the latest stable version of pytest?
    

    💡 Result:

    The latest stable version of pytest as of February 2025 is 8.3.4, released on December 1, 2024[1][2][4][6]. This version includes bug fixes for crashes related to directory layouts, assertion rewriting improvements, and stricter boolean handling in pytest.approx[2][4].

    Key details:

    • Python compatibility: Requires Python 3.8+ or PyPy3[1][5]
    • Installation command:
      pip install -U pytest
      This will install/upgrade to the latest stable version[5][6].

    Recent updates focus on:

    • Improved ANSI code handling for colored output[2]
    • Better cache directory permissions (defaulting to rwxr-xr-x)[2]
    • Enhanced namespace package detection[2]

    For production environments, verify installation with:

    pytest --version
    # Output: pytest 8.3.4

    Citations:


    LGTM! Consider pinning the pytest version to ensure a consistent test environment.

    The transition from Poetry to UV is correctly reflected by running pytest via uv run. However, rather than pinning an older version (e.g., pytest==8.0.0), you should update the command to pin the latest stable release (as of February 2025, pytest 8.3.4) to avoid any unexpected discrepancies.

    • Update the hook entry to:
      -        entry: uv run pytest --cov=pyretailscience --cov-report=xml --cov-branch tests
      +        entry: uv run pytest==8.3.4 --cov=pyretailscience --cov-report=xml --cov-branch tests
    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 31526f0 and 021d2ff.

    📒 Files selected for processing (1)
    • .pre-commit-config.yaml (1 hunks)

    Copy link

    codecov bot commented Feb 12, 2025

    Codecov Report

    Attention: Patch coverage is 85.40146% with 20 lines in your changes missing coverage. Please review.

    Files with missing lines Patch % Lines
    pyretailscience/plots/waterfall.py 74.41% 8 Missing and 3 partials ⚠️
    pyretailscience/plots/index.py 85.71% 4 Missing and 5 partials ⚠️
    Files with missing lines Coverage Δ
    pyretailscience/plots/time.py 100.00% <100.00%> (ø)
    pyretailscience/style/graph_utils.py 81.34% <100.00%> (+4.82%) ⬆️
    pyretailscience/plots/index.py 85.71% <85.71%> (ø)
    pyretailscience/plots/waterfall.py 74.41% <74.41%> (ø)

    ... and 2 files with indirect coverage changes

    @mayurkmmt mayurkmmt force-pushed the feature/refactor-standard-graph-plots branch from 021d2ff to 8779a44 Compare February 12, 2025 10:52
    Copy link
    Contributor

    @mvanwyk mvanwyk left a comment

    Choose a reason for hiding this comment

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

    LGTM!

    @mayurkmmt mayurkmmt merged commit 26270d5 into main Feb 12, 2025
    3 of 4 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants