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

[Proposal] rename ctx.create_store to ctx.store #4954

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

imanjra
Copy link
Contributor

@imanjra imanjra commented Oct 21, 2024

What changes are proposed in this pull request?

Add ctx.store and deprecate cts.create_store

How is this patch tested? If it is not, please explain why.

(Details)

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features

    • Introduced a new store method for enhanced store management, allowing for scoped store names based on operator URI.
    • Retained the original create_store method as deprecated, guiding users to transition to the new method.
  • Bug Fixes

    • Added logging to the set_progress method to improve error handling when progress is set without a defined function.
  • Documentation

    • Updated the store method's documentation to reflect its new functionality and usage.
    • Revised the documentation for the deprecated create_store method to provide transition guidance.

@imanjra imanjra requested a review from ritch October 21, 2024 16:54
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

40 files out of 122 files are above the max files limit of 75. Please upgrade to Pro plan to get higher limits.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes involve significant updates to the Executor class within the fiftyone/operators/executor.py file. The primary modification is the renaming of the create_store method to store, which now includes enhanced functionality to create and utilize a store with the specified name if it does not already exist. The original create_store method is deprecated but retains its functionality while redirecting users to the new method. Additionally, minor adjustments were made to the set_progress method to improve logging.

Changes

File Path Change Summary
fiftyone/operators/executor.py - Renamed create_store method to store with new functionality for creating and using a store.
- Added a deprecated create_store method that retains original functionality.
- Updated docstring for store method to reflect new functionality.
- Added logging statement in set_progress method for cases without a _set_progress function.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Executor
    participant Store

    User->>Executor: Call store(store_name)
    Executor->>Executor: Check if store exists
    alt Store does not exist
        Executor->>Store: Create scoped store with specified name
    end
    Executor->>User: Return scoped store
Loading

🐇 "In the land of code, a change took flight,
The store now shines, a new path in sight.
With names scoped neatly, and progress in tow,
Our Executor hops forth, ready to grow!" 🐇

Possibly related PRs

  • Execution Store #4827: The changes in the ExecutionStore PR involve a create_store method, which is directly related to the renaming and deprecation of the create_store method in the Executor class of the main PR. Both PRs deal with store management functionality, indicating a strong connection at the code level.

Suggested labels

feature

Suggested reviewers

  • lanzhenw
  • manivoxel51

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 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.

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.

@imanjra imanjra changed the title store accessor tweaks [Proposal] store accessor tweaks Oct 21, 2024
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

🧹 Outside diff range and nitpick comments (2)
fiftyone/operators/executor.py (2)

Line range hint 850-864: New method store looks good, but consider adding error handling.

The new store method is well-implemented and provides a clear improvement over the deprecated create_store method. It creates a scoped store name, which helps prevent naming conflicts between different operators. However, there are a couple of suggestions for improvement:

  1. Consider adding error handling in case the ExecutionStore.create method fails.
  2. The docstring could be more detailed, explaining the scoping of the store name and any potential side effects.

Here's a suggested improvement with error handling and an expanded docstring:

def store(self, store_name):
    """
    Create (if not previously created) and use a store with the specified name.

    This method creates a scoped store name by prefixing the given store_name
    with the operator's URI. This ensures unique store names across different
    operators.

    Args:
        store_name: the name of the store

    Returns:
        a :class:`fiftyone.operators.store.ExecutionStore`

    Raises:
        RuntimeError: If the store creation fails
    """
    from fiftyone.operators.store import ExecutionStore

    scoped_store_name = f"{self._operator_uri}_{store_name}"

    try:
        return ExecutionStore.create(scoped_store_name)
    except Exception as e:
        raise RuntimeError(f"Failed to create store '{scoped_store_name}': {str(e)}")

867-879: Deprecation of create_store method is handled correctly.

The deprecation of the create_store method is implemented correctly. It provides a clear message to users about using the new store method instead. The implementation also ensures backward compatibility by calling the new store method.

Consider adding a deprecation warning to make it more visible to users:

import warnings

def create_store(self, store_name):
    """
    DEPRECATED: use `ctx.store('my_store')` instead.

    Creates a new store with the specified name.

    Args:
        store_name: the name of the store

    Returns:
        a :class:`fiftyone.operators.store.ExecutionStore`
    """
    warnings.warn(
        "The 'create_store' method is deprecated. Use 'store' method instead.",
        DeprecationWarning,
        stacklevel=2
    )
    return self.store(store_name)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2631236 and 16919f5.

📒 Files selected for processing (1)
  • fiftyone/operators/executor.py (2 hunks)
🧰 Additional context used

@imanjra imanjra force-pushed the chore/store-tweaks branch from 16919f5 to 7e64a0d Compare October 21, 2024 17:01
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

🧹 Outside diff range and nitpick comments (1)
fiftyone/operators/executor.py (1)

864-877: LGTM! Well-handled deprecation.

The create_store method is correctly marked as deprecated and redirects to the new store method. This approach maintains backward compatibility while encouraging users to switch to the new API.

Consider adding a deprecation warning using the warnings module to provide a more visible alert to users still using this method. For example:

import warnings

def create_store(self, store_name):
    warnings.warn(
        "The 'create_store' method is deprecated. Use 'ctx.store(store_name)' instead.",
        DeprecationWarning,
        stacklevel=2
    )
    return self.store(store_name)

This will emit a warning when the method is called, making it easier for developers to identify and update deprecated code usage.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 16919f5 and 7e64a0d.

📒 Files selected for processing (1)
  • fiftyone/operators/executor.py (2 hunks)
🧰 Additional context used
🔇 Additional comments (1)
fiftyone/operators/executor.py (1)

Line range hint 850-857: LGTM! Improved store creation and usage.

The new store method is a well-designed replacement for the deprecated create_store. It provides a more intuitive API by combining the creation and usage of a store in a single method. The implementation is concise and correct.

Base automatically changed from feat/execution-store to develop October 21, 2024 20:23
@imanjra imanjra force-pushed the chore/store-tweaks branch from 7e64a0d to 6be85f3 Compare October 22, 2024 13:19
@imanjra imanjra changed the title [Proposal] store accessor tweaks [Proposal] rename ctx.create_store to ctx.store Oct 22, 2024
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

🧹 Outside diff range and nitpick comments (1)
fiftyone/operators/executor.py (1)

Line range hint 875-883: LGTM! Consider adding a minor clarification to the docstring.

The implementation of the store method looks good. It correctly creates (if not already created) and uses a store with the specified name, returning an ExecutionStore object. This aligns with the PR objective of replacing the deprecated create_store method.

Consider adding a brief explanation of what a "store" is in the context of FiftyOne operations to the docstring. This would improve clarity for developers who might be new to the concept. For example:

 def store(self, store_name):
     """
     Create (if not previously created) and use a store with the specified name.
+
+    A store in FiftyOne is a persistent key-value storage mechanism used for
+    caching data across multiple operator executions.

     Args:
         store_name: the name of the store

     Returns:
         a :class:`fiftyone.operators.store.ExecutionStore`
     """
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7e64a0d and 6be85f3.

📒 Files selected for processing (1)
  • fiftyone/operators/executor.py (1 hunks)
🧰 Additional context used

ritch
ritch previously approved these changes Oct 31, 2024
@imanjra imanjra changed the base branch from develop to release/v1.1.0 November 12, 2024 15:46
@imanjra imanjra dismissed ritch’s stale review November 12, 2024 15:46

The base branch was changed.

@imanjra imanjra merged commit e63f025 into release/v1.1.0 Nov 13, 2024
1 check passed
@imanjra imanjra deleted the chore/store-tweaks branch November 13, 2024 16:57
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