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

Add FrameNumberField support for lightning queries #5093

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Nov 12, 2024

What changes are proposed in this pull request?

Adds missing FrameNumberField support for lightning queries. With QP enabled, the below field will error when expanding it in the sidebar

import fiftyone as fo
import fiftyone.zoo as foz 

dataset = foz.load_zoo_dataset("quickstart")
dataset.add_sample_field("frame_number", fo.FrameNumberField)

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

Unit tests

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 support for handling frame number fields in lightning queries, allowing structured responses similar to integer fields.
  • Tests

    • Added a new test class to validate integer-related queries in the Lightning API, enhancing test coverage for integer fields.

@benjaminpkane benjaminpkane added app Issues related to App features server Issues related to server features or changes labels Nov 12, 2024
@benjaminpkane benjaminpkane self-assigned this Nov 12, 2024
Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

Walkthrough

This pull request introduces a new mapping for fof.FrameNumberField to IntLightningResult in the INT_CLS dictionary within the fiftyone/server/lightning.py file. This change allows the framework to handle frame number fields in lightning queries similarly to integer fields. Additionally, a new test class, TestIntLightningQueries, is added to tests/unittests/lightning_tests.py, which includes asynchronous tests to validate integer-related queries in the Lightning API.

Changes

File Change Summary
fiftyone/server/lightning.py Added mapping for fof.FrameNumberField to IntLightningResult in INT_CLS.
tests/unittests/lightning_tests.py Added TestIntLightningQueries class with an asynchronous method test_ints to validate integer queries.

Possibly related PRs

  • Summary fields should support frame-level input paths #4841: The changes in this PR enhance the handling of frame fields in the dataset, which is directly related to the new mapping for fof.FrameNumberField in the main PR, as both involve processing frame-level data within the FiftyOne framework.

Suggested labels

bug

Suggested reviewers

  • ritch
  • minhtuev

🐇 In the land where frames do play,
A new field joins the light of day.
With integers now side by side,
Queries dance, and data glide.
In tests we hop, with joy we cheer,
For every frame, the truth is clear! 🥕


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.

@benjaminpkane benjaminpkane changed the base branch from develop to release/v1.1.0 November 12, 2024 16:08
Copy link
Contributor

@CamronStaley CamronStaley left a comment

Choose a reason for hiding this comment

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

awesome thanks for this Ben

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: 1

🧹 Outside diff range and nitpick comments (1)
tests/unittests/lightning_tests.py (1)

291-295: Consider adding edge cases for frame numbers

While the basic test cases are good, consider adding edge cases such as:

  • Zero frame numbers
  • Negative frame numbers (if supported)
  • Large frame numbers
 keys = _add_samples(
     dataset,
-    dict(ints=1, frame_numbers=1, frame_supports=[1, 1]),
-    dict(ints=2, frame_numbers=2, frame_supports=[2, 2]),
+    dict(ints=1, frame_numbers=0, frame_supports=[1, 1]),
+    dict(ints=2, frame_numbers=999999, frame_supports=[2, 2]),
 )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 852d6dc and 59b0401.

📒 Files selected for processing (2)
  • fiftyone/server/lightning.py (1 hunks)
  • tests/unittests/lightning_tests.py (1 hunks)
🔇 Additional comments (4)
tests/unittests/lightning_tests.py (4)

285-290: LGTM: Test class setup follows established patterns

The test class correctly extends unittest.IsolatedAsyncioTestCase and properly sets up the required fields using appropriate field types.


297-308: LGTM: GraphQL query is well-structured

The query correctly uses the IntLightningResult type and requests all necessary fields (max, min, path).


309-314: LGTM: Test execution properly includes all integer field types

The test correctly includes all three field types (FrameNumberField, FrameSupportField, IntField) in the execution.


316-374: Verify comprehensive path coverage

The assertions cover all possible paths for integer fields in the dataset schema. However, let's verify that no paths are missing.

✅ Verification successful

Comprehensive path coverage verified.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all possible integer field paths are covered in the test assertions

# Search for all field path patterns in the codebase
rg -U "path.*frame_(numbers|supports)" | grep -v "test_ints"

# Search for any additional integer field types that might need testing
ast-grep --pattern 'class $name extends IntField {
  $$$
}'

Length of output: 1544

fiftyone/server/lightning.py Show resolved Hide resolved
@benjaminpkane benjaminpkane merged commit e3d90a4 into release/v1.1.0 Nov 12, 2024
1 check passed
@benjaminpkane benjaminpkane deleted the bugfix/lightning-server-frame-fields branch November 12, 2024 16:42
sashankaryal pushed a commit that referenced this pull request Nov 15, 2024
* add missing frame number and frame support field support for lightning queries

* rm frame support, not applicable
@coderabbitai coderabbitai bot mentioned this pull request Nov 15, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Issues related to App features server Issues related to server features or changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants