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 target view for clear sample/frame field operators #5122

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

brimoor
Copy link
Contributor

@brimoor brimoor commented Nov 15, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced ClearSampleField and ClearFrameField operators to allow clearing fields in specific views or the entire dataset.
    • Users can now specify whether to clear fields for selected samples or the current view, improving flexibility.
  • Bug Fixes

    • Resolved issues with input resolution to align with the new functionality for handling the target parameter.

@brimoor brimoor added the bug Bug fixes label Nov 15, 2024
Copy link
Contributor

coderabbitai bot commented Nov 15, 2024

Walkthrough

The changes in this pull request modify the ClearSampleField and ClearFrameField classes in fiftyone/operators/builtin.py. Both classes' execute methods now include a new target parameter, allowing for operations on specific views rather than solely on the dataset. This adjustment enhances flexibility by enabling the clearing of fields based on the specified target view. Additionally, the input resolution methods have been updated to accommodate the target parameter, ensuring that users can specify the scope of their operations.

Changes

File Change Summary
fiftyone/operators/builtin.py Updated execute method in ClearSampleField and ClearFrameField to include target parameter.
fiftyone/operators/builtin.py Modified _clear_sample_field_inputs and _clear_frame_field_inputs to handle target parameter.

Poem

In fields so clear, a rabbit hops,
With changes made, the old way stops.
A target view, now in our sights,
We clear with joy, as day turns to nights.
Hooray for fields, both near and far,
Our dataset shines, like a bright, new star! ✨🐇


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.

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/builtin.py (2)

625-629: Consider refactoring duplicate code in execute methods

Both ClearSampleField.execute and ClearFrameField.execute contain similar code for handling the target parameter and obtaining target_view. To adhere to the DRY principle, consider extracting this common logic into a shared method or utility function to improve maintainability.

Also applies to: 719-723


Line range hint 635-686: Refactor duplicated input resolution logic in _clear_sample_field_inputs and _clear_frame_field_inputs

The functions _clear_sample_field_inputs and _clear_frame_field_inputs share similar logic for constructing target_choices and handling the target parameter. Refactoring this shared code into a common utility function would reduce duplication and enhance readability.

Also applies to: 729-780

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 02ae185 and 6ff3d05.

📒 Files selected for processing (1)
  • fiftyone/operators/builtin.py (2 hunks)
🔇 Additional comments (2)
fiftyone/operators/builtin.py (2)

625-629: Implemented target parameter handling in ClearSampleField.execute

The execute method now retrieves the target parameter and obtains the corresponding target_view using _get_target_view. This change allows for clearing sample fields on specific views, enhancing the operator's flexibility.


719-723: Added target parameter support in ClearFrameField.execute

The execute method in ClearFrameField now correctly handles the target parameter and obtains the appropriate target_view, enabling the clearing of frame fields on specified views.

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.

Lgtm

Copy link
Contributor

@imanjra imanjra left a comment

Choose a reason for hiding this comment

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

LGTM

@brimoor brimoor merged commit f9770af into release/v1.1.0 Nov 15, 2024
13 checks passed
@brimoor brimoor deleted the bug-clear-fields branch November 15, 2024 15:16
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.

3 participants