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

Bugfix: support branches that contain slashes when downloading plugins #4614

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

brimoor
Copy link
Contributor

@brimoor brimoor commented Aug 4, 2024

Resolves #4610

Tested by

Verifying that we can download a plugin from a branch that contains a slash:

export FIFTYONE_PLUGINS_DIR=/tmp/plugins

# Download a plugin from branch `feature/update-index-plugin` that contains a slash
fiftyone plugins download \
    https://github.com/voxel51/fiftyone-plugins/tree/feature/update-index-plugin \
    --plugin-names '@voxel51/indexes'

rm -rf /tmp/plugins
unset FIFTYONE_PLUGINS_DIR

Also verified that all relevant syntaxes in fiftyone.plugins.utils work as expected:

import fiftyone.plugins.utils as fopu

plugins = fopu.list_zoo_plugins()
plugins = fopu.list_zoo_plugins(info=True)

plugins = fopu.find_plugins("https://github.com/voxel51/fiftyone-plugins")
plugins = fopu.find_plugins("https://github.com/voxel51/fiftyone-plugins/tree/main", path="plugins/annotation")

info = fopu.get_plugin_info("https://github.com/voxel51/voxelgpt")
info = fopu.get_plugin_info("https://github.com/voxel51/fiftyone-plugins/tree/main/plugins/annotation")
info = fopu.get_plugin_info("https://github.com/voxel51/fiftyone-plugins/blob/main/plugins/annotation/fiftyone.yml")
info = fopu.get_plugin_info("voxel51/fiftyone-plugins", path="plugins/annotation")
info = fopu.get_plugin_info("voxel51/fiftyone-plugins", path="plugins/annotation/fiftyone.yml")

Summary by CodeRabbit

  • New Features

    • Enhanced plugin search capabilities with the ability to specify subdirectories in GitHub repositories.
    • Improved access to plugin information by allowing path specifications for YAML files or directories.
  • Bug Fixes

    • Refined GitHub URL parsing logic to support a broader range of valid URLs.
  • Tests

    • Added a new test for verifying GitHub repository URL parsing, improving test coverage.
  • Documentation

    • Updated documentation for functions and classes to enhance clarity on expected inputs and usage.

@brimoor brimoor added the bug Bug fixes label Aug 4, 2024
@brimoor brimoor requested a review from a team August 4, 2024 20:26
Copy link
Contributor

coderabbitai bot commented Aug 4, 2024

Walkthrough

The recent changes enhance the fiftyone library's plugin functionality by allowing more flexible interactions with GitHub repositories. Key modifications include added parameters for specifying paths within repositories, improved parsing logic, and expanded testing for URL formats. These updates improve user experience and address issues related to branch naming conventions, enhancing the overall robustness of the plugin system.

Changes

Files Change Summary
fiftyone/plugins/utils.py Enhanced find_plugins and get_plugin_info functions with a new path parameter for better GitHub repo handling.
fiftyone/utils/github.py Updated GitHubRepository class methods for improved URL parsing and clearer documentation.
tests/unittests/plugins/core_tests.py Added new test test_github_repository_parse_url to verify GitHub URL parsing functionality.
tests/unittests/plugins/secrets_tests.py Organized imports and added a module-level docstring for clarity.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PluginSystem
    participant GitHubRepository

    User->>PluginSystem: Request to find plugins
    PluginSystem->>GitHubRepository: Fetch repository plugins with path
    GitHubRepository-->>PluginSystem: Return plugin information
    PluginSystem-->>User: Provide plugin list
Loading

Assessment against linked issues

Objective Addressed Explanation
Cannot download plugins from branches with slashes (4610)

🐇 In the fields where plugins grow,
Changes made to help them flow.
With paths now clear, the branches sing,
A better way for plugins to spring!
Let's hop along, our joy to share,
In the world of code, we show we care! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c6c4abb and a7eb2aa.

Files selected for processing (4)
  • fiftyone/plugins/utils.py (5 hunks)
  • fiftyone/utils/github.py (3 hunks)
  • tests/unittests/plugins/core_tests.py (2 hunks)
  • tests/unittests/plugins/secrets_tests.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/unittests/plugins/secrets_tests.py
Additional comments not posted (5)
tests/unittests/plugins/core_tests.py (1)

157-176: Test cases are well-structured and comprehensive.

The new test function test_github_repository_parse_url covers various GitHub URL formats, ensuring robust parsing logic.

Ensure that these test cases cover all relevant scenarios for GitHub URL parsing.

fiftyone/utils/github.py (2)

231-243: Method changes are well-implemented.

The updated parse_identifier method correctly parses the identifier and improves internal logic.

Ensure that the method correctly parses the identifier and handles edge cases.

Verification successful

Method changes are well-implemented.

The updated parse_identifier method correctly parses the identifier and improves internal logic. No issues found with the implementation or usage.

  • fiftyone/utils/github.py: The parse_identifier method is correctly defined and used within the same file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the identifier parsing coverage.

# Test: Ensure the method correctly parses the identifier and handles edge cases.
rg --type python -A 5 $'parse_identifier'

Length of output: 71


Script:

#!/bin/bash
# Description: Verify the identifier parsing coverage.

# Test: Ensure the method correctly parses the identifier and handles edge cases.
rg --type py -A 5 $'parse_identifier'

Length of output: 1470


Line range hint 220-226:
Regex pattern update is well-implemented.

The updated regex pattern in parse_url method enhances the parsing logic for GitHub URLs.

Ensure that the regex pattern correctly captures all relevant parts of the URL and handles edge cases.

Verification successful

Regex pattern update is well-implemented and thoroughly tested.

The parse_url method's regex pattern in fiftyone/utils/github.py is well-formed and has been verified through comprehensive test cases in tests/unittests/plugins/core_tests.py. These tests cover various GitHub URL formats, ensuring robust parsing.

  • tests/unittests/plugins/core_tests.py: Test cases for parse_url method.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the regex pattern coverage for GitHub URL parsing.

# Test: Ensure the regex pattern correctly captures all relevant parts of the URL.
rg --type python -A 5 $'parse_url'

Length of output: 64


Script:

#!/bin/bash
# Description: Verify the regex pattern coverage for GitHub URL parsing.

# Test: Ensure the regex pattern correctly captures all relevant parts of the URL.
rg 'def parse_url' -A 10 fiftyone/utils/github.py

Length of output: 376


Script:

#!/bin/bash
# Description: Verify the test coverage for the `parse_url` method.

# Test: Search for test cases related to the `parse_url` method.
rg 'parse_url' -A 5

Length of output: 3015

fiftyone/plugins/utils.py (2)

Line range hint 70-106:
Function changes are well-implemented.

The updated find_plugins function correctly integrates the new path parameter, enhancing its capability.

Ensure that the new parameter is correctly integrated and enhances the function's capability.

Verification successful

Let's correct the previous script and gather the necessary information to verify the integration of the path parameter in the find_plugins function.


Function changes are well-implemented.

The updated find_plugins function correctly integrates the new path parameter, enhancing its capability.

  • The function definition includes the path parameter.
  • The implementation contains logic to filter repository contents based on the path value.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the new `path` parameter in `find_plugins`.

# Test: Ensure the new parameter is correctly integrated and enhances the function's capability.
rg --type python -A 5 $'find_plugins'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify the integration of the new `path` parameter in `find_plugins`.

# Search for the `find_plugins` function definition
ast-grep --lang python --pattern $'def find_plugins($_, $_, $_):\n  $$$'

# Search for the usage of the `find_plugins` function in the codebase
rg 'find_plugins' -A 5

Length of output: 4391


Line range hint 132-198:
Function changes are well-implemented.

The updated get_plugin_info function correctly integrates the new path parameter, enhancing its capability.

Ensure that the new parameter is correctly integrated and enhances the function's capability.

Verification successful

Function changes are well-implemented.

The updated get_plugin_info function correctly integrates the new path parameter, enhancing its capability. The function's logic and its usages within the codebase confirm the correct integration and effective utilization of the new parameter.

  • The get_plugin_info function implementation starts at line 125 in fiftyone/plugins/utils.py.
  • Multiple usages of the get_plugin_info function within the same file demonstrate the correct integration of the path parameter.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the new `path` parameter in `get_plugin_info`.

# Test: Ensure the new parameter is correctly integrated and enhances the function's capability.
rg --type python -A 5 $'get_plugin_info'

Length of output: 70


Script:

#!/bin/bash
# Description: Verify the integration of the new `path` parameter in `get_plugin_info`.

# Test: Ensure the new parameter is correctly integrated and enhances the function's capability.
rg --type py -A 10 'def get_plugin_info'

Length of output: 670


Script:

#!/bin/bash
# Description: Verify the integration of the new `path` parameter in `get_plugin_info`.

# Extract the complete implementation of the `get_plugin_info` function.
ast-grep --lang python --pattern $'def get_plugin_info(gh_repo, path=None):\n    $$$\n'

# Search for the usage of the `get_plugin_info` function in the codebase.
rg 'get_plugin_info'

Length of output: 6666

@brimoor brimoor changed the base branch from develop to release/v0.25.0 August 5, 2024 16:41
Copy link
Contributor

@swheaton swheaton left a comment

Choose a reason for hiding this comment

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

reviewed, tested; lgtm

@brimoor brimoor merged commit d84f325 into release/v0.25.0 Aug 6, 2024
13 checks passed
@brimoor brimoor deleted the bug/iss-4610 branch August 6, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Cannot download plugins from branches that contain slashes '/'
2 participants