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

fix: Fixed pinecone tests #414

Merged
merged 10 commits into from
Sep 19, 2024
Merged

fix: Fixed pinecone tests #414

merged 10 commits into from
Sep 19, 2024

Conversation

Vits-99
Copy link
Contributor

@Vits-99 Vits-99 commented Sep 5, 2024

User description

  • Fixed and introduced pinecone index tests
  • Introduced sync tests
  • Minor fixes

PR Type

Bug fix, Tests


Description

  • Improved synchronization logic in pinecone.py by adding checks for empty function_schemas and setting them to None if empty.
  • Enhanced error handling in layer.py by adding try-except blocks for route deletion and adjusting dimensions handling.
  • Added new test cases in test_layer.py to verify Pinecone index synchronization and introduced time delays to ensure index population.
  • Updated existing tests to include metadata checks and improved test reliability with Pinecone index.

Changes walkthrough 📝

Relevant files
Bug fix
pinecone.py
Improve synchronization logic and error handling in Pinecone index

semantic_router/index/pinecone.py

  • Added checks for empty function_schemas and set them to None if empty.
  • Improved synchronization logic for routes.
  • Enhanced handling of local and remote utterances and metadata.
  • +58/-15 
    Enhancement
    layer.py
    Enhance error handling and logging in route layer               

    semantic_router/layer.py

  • Added error handling for route deletion.
  • Adjusted dimensions handling in _add_and_sync_routes.
  • Improved logging and removed redundant logs.
  • +10/-8   
    Tests
    test_layer.py
    Add and update tests for Pinecone index synchronization   

    tests/unit/test_layer.py

  • Added new test cases for Pinecone index synchronization.
  • Introduced time delays for Pinecone index population.
  • Updated existing tests to include metadata checks.
  • +162/-34

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link

    github-actions bot commented Sep 5, 2024

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Code Redundancy
    The conditional checks for local_function_schemas and remote_function_schemas being truthy before setting them to None are repeated multiple times across the _sync_index method. Consider refactoring this logic into a helper function to reduce redundancy and improve code maintainability.

    Error Handling
    The exception handling for deleting a route from the index only logs the error without rethrowing or handling it further. This might lead to silent failures where the system believes a route has been deleted when it has not. Consider how this should be handled, possibly by rethrowing the exception or implementing a retry mechanism.

    Copy link

    github-actions bot commented Sep 5, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Simplify the conditional assignment to a more concise expression

    Replace the conditional assignment with a more concise expression using the or
    operator.

    semantic_router/index/pinecone.py [298-300]

    -"function_schemas": (
    -    local_function_schemas if local_function_schemas else None
    -),
    +"function_schemas": local_function_schemas or None,
     
    Suggestion importance[1-10]: 7

    Why: The suggestion simplifies the conditional assignment by using the or operator, which is a more concise and idiomatic way to achieve the same result. This improves code readability without altering functionality. However, the improvement is minor and does not address any critical issues.

    7

    Copy link

    codecov bot commented Sep 19, 2024

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 67.99%. Comparing base (413f147) to head (0196644).
    Report is 11 commits behind head on main.

    Additional details and impacted files
    @@            Coverage Diff             @@
    ##             main     #414      +/-   ##
    ==========================================
    + Coverage   62.53%   67.99%   +5.45%     
    ==========================================
      Files          46       46              
      Lines        3465     3465              
    ==========================================
    + Hits         2167     2356     +189     
    + Misses       1298     1109     -189     

    ☔ View full report in Codecov by Sentry.
    📢 Have feedback on the report? Share it here.

    @jamescalam jamescalam merged commit 3e6bd22 into main Sep 19, 2024
    8 checks passed
    @jamescalam jamescalam deleted the vittorio/fix-pinecone-tests branch September 19, 2024 21:54
    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