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

get dynamic groups target frame rate from app config instead of harcoded value #5368

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

sashankaryal
Copy link
Contributor

@sashankaryal sashankaryal commented Jan 9, 2025

What changes are proposed in this pull request?

Right now target frame rate for imavid is set to 30. This PR exposes a dataset app config property called dynamicGroupsTargetFrameRate which allows customers to declare it per dataset. The default is still 30.

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

import fiftyone.zoo as foz
import fiftyone as fo

d = foz.load_zoo_dataset("quickstart-video")

frames_d = d.to_frames(sample_frames=True).clone()

frames_d.app_config.dynamic_groups_target_frame_rate = 10
frames_d.save()

grouped_view = frames_d.group_by("sample_id", order_by="frame_number")

session = fo.launch_app(grouped_view)
session.wait(-1)

In the app, select "Render frames as video" and observe that frame rate is ~10. In a shell or using an operator from the UI, change the target frame rate again, refresh the app, and see that it's different. Verify it both in the grid and in the modal.

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.

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 dynamic target frame rate for groups
    • Added configuration option to customize frame rate for video rendering
  • Improvements

    • Enhanced frame rate management across multiple components
    • Increased flexibility in playback and rendering settings
  • Technical Updates

    • Updated GraphQL schema to support new frame rate configuration
    • Modified state management to handle dynamic frame rates

@sashankaryal sashankaryal requested a review from a team January 9, 2025 23:23
@sashankaryal sashankaryal self-assigned this Jan 9, 2025
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

This pull request introduces a new dynamicGroupsTargetFrameRate configuration across multiple packages, enabling dynamic frame rate management for video and image group rendering. The changes span frontend (React), backend (Python), and GraphQL schema, adding a configurable frame rate with a default of 30. The modification involves updating state management, controller logic, and configuration interfaces to support more flexible frame rate handling in dynamic group scenarios.

Changes

File Change Summary
app/packages/core/src/components/Modal/ImaVidLooker.tsx Added dynamicGroupsTargetFrameRate state variable
app/packages/looker/src/elements/imavid/index.ts Added targetFrameRate property, updated renderSelf method
app/packages/looker/src/lookers/imavid/constants.ts Removed DEFAULT_FRAME_RATE constant
app/packages/looker/src/lookers/imavid/controller.ts Replaced frameRate with targetFrameRate, updated methods
app/packages/looker/src/util.ts Modified getMillisecondsFromPlaybackRate to accept frame rate
app/packages/relay/src/fragments/datasetAppConfigFragment.ts Added dynamicGroupsTargetFrameRate field
app/packages/state/src/hooks/useCreateLooker.ts Integrated dynamic frame rate in looker creation
app/packages/state/src/recoil/selectors.ts Added dynamicGroupsTargetFrameRate selector
app/packages/state/src/recoil/types.ts Added dynamicGroupsTargetFrameRate to DatasetAppConfig
app/schema.graphql Added required dynamicGroupsTargetFrameRate field
fiftyone/core/odm/dataset.py Added dynamic_groups_target_frame_rate attribute
fiftyone/server/query.py Added dynamic_groups_target_frame_rate field

Sequence Diagram

sequenceDiagram
    participant UI as User Interface
    participant State as Recoil State
    participant Looker as ImaVidLooker
    participant Controller as ImaVidFramesController

    UI->>State: Set dynamicGroupsTargetFrameRate
    State->>Looker: Provide dynamicGroupsTargetFrameRate
    Looker->>Controller: Initialize with targetFrameRate
    Controller-->>Looker: Configure rendering parameters
Loading

Possibly related PRs

Suggested labels

feature, configuration, video-rendering

Suggested reviewers

  • benjaminpkane
  • videotech-lead
  • state-management-expert

Poem

🐰 Frames dancing to a new beat,
Dynamic groups now complete!
Thirty ticks per second's might,
Rendering magic, pure delight!
A rabbit's code, both swift and bright! 🎥

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@sashankaryal sashankaryal added the app Issues related to App features label Jan 9, 2025
@sashankaryal
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (2)
app/packages/looker/src/lookers/imavid/controller.ts (1)

186-187: Consider documenting the frame rate limit change.

The maximum frame rate has been increased from 24 to 60 FPS, which allows for smoother playback on capable displays. Consider adding a code comment explaining this change and its benefits.

Also applies to: 194-194

fiftyone/server/query.py (1)

214-214: Add docstring documentation for the new field.

The new field dynamic_groups_target_frame_rate lacks docstring documentation. Consider adding a description to maintain consistency with other fields in the class.

+    """The target frame rate when rendering ordered dynamic groups of images as videos."""
     dynamic_groups_target_frame_rate: int = 30
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60971f8 and 49ad300.

⛔ Files ignored due to path filters (3)
  • app/packages/app/src/pages/datasets/__generated__/DatasetPageQuery.graphql.ts is excluded by !**/__generated__/**, !**/__generated__/**
  • app/packages/relay/src/fragments/__generated__/datasetAppConfigFragment.graphql.ts is excluded by !**/__generated__/**, !**/__generated__/**
  • app/packages/relay/src/queries/__generated__/datasetQuery.graphql.ts is excluded by !**/__generated__/**, !**/__generated__/**
📒 Files selected for processing (12)
  • app/packages/core/src/components/Modal/ImaVidLooker.tsx (2 hunks)
  • app/packages/looker/src/elements/imavid/index.ts (4 hunks)
  • app/packages/looker/src/lookers/imavid/constants.ts (0 hunks)
  • app/packages/looker/src/lookers/imavid/controller.ts (6 hunks)
  • app/packages/looker/src/util.ts (1 hunks)
  • app/packages/relay/src/fragments/datasetAppConfigFragment.ts (1 hunks)
  • app/packages/state/src/hooks/useCreateLooker.ts (4 hunks)
  • app/packages/state/src/recoil/selectors.ts (1 hunks)
  • app/packages/state/src/recoil/types.ts (1 hunks)
  • app/schema.graphql (1 hunks)
  • fiftyone/core/odm/dataset.py (2 hunks)
  • fiftyone/server/query.py (1 hunks)
💤 Files with no reviewable changes (1)
  • app/packages/looker/src/lookers/imavid/constants.ts
🧰 Additional context used
📓 Path-based instructions (8)
app/packages/state/src/recoil/types.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/relay/src/fragments/datasetAppConfigFragment.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/state/src/recoil/selectors.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/core/src/components/Modal/ImaVidLooker.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/looker/src/util.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/state/src/hooks/useCreateLooker.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/looker/src/lookers/imavid/controller.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/looker/src/elements/imavid/index.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

🔇 Additional comments (14)
app/packages/relay/src/fragments/datasetAppConfigFragment.ts (1)

9-9: LGTM!

The new field follows the existing naming convention and is correctly positioned in the fragment.

app/packages/state/src/recoil/types.ts (1)

122-122: LGTM!

The new property is well-typed and maintains consistency with the GraphQL schema.

app/packages/looker/src/lookers/imavid/controller.ts (1)

17-17: LGTM!

The refactoring from frameRate to targetFrameRate is consistent and well-implemented.

Also applies to: 35-35, 44-44

app/packages/state/src/hooks/useCreateLooker.ts (1)

66-68: LGTM!

The integration of the dynamic frame rate configuration is well-implemented, following React and Recoil best practices.

Also applies to: 234-234, 244-244

app/packages/core/src/components/Modal/ImaVidLooker.tsx (3)

40-42: LGTM! Clean introduction of the frame rate configuration.

The new Recoil state variable is well-integrated and follows React hooks best practices.


226-227: LGTM! Proper integration of dynamic frame rate in timeline config.

The frame rate is correctly incorporated into the timeline configuration object, with appropriate dependency tracking in the useMemo hook.


Line range hint 451-458: LGTM! Proper handling of frame rate and timeout delay.

The frame rate initialization and timeout delay calculation are implemented correctly, with appropriate conditional checks to prevent unnecessary recalculations.

app/packages/looker/src/util.ts (1)

256-261: LGTM! Clean function signature update.

The function has been properly modified to accept a dynamic frame rate parameter while maintaining the correct calculation logic.

app/packages/state/src/recoil/selectors.ts (1)

160-165: LGTM! Well-structured Recoil selector.

The selector is properly implemented with:

  • Correct TypeScript typing
  • Appropriate default value handling
  • Consistent naming convention
app/packages/looker/src/elements/imavid/index.ts (3)

83-84: LGTM! Well-defined class properties.

The new private properties are properly typed and follow TypeScript best practices.


351-353: LGTM! Proper adaptation of look-ahead calculation.

The offset calculation has been correctly updated to use the dynamic frame rate while maintaining the original logic structure.


453-458: LGTM! Proper timeout delay calculation update.

The timeout delay calculation has been correctly updated with:

  • Appropriate conditional check for recalculation
  • Correct parameter passing to getMillisecondsFromPlaybackRate
fiftyone/core/odm/dataset.py (1)

530-531: LGTM!

The new field is well-documented and properly implemented with appropriate type and default value.

Also applies to: 550-550

app/schema.graphql (1)

251-251: LGTM!

The GraphQL schema change is correctly implemented with appropriate type constraints and naming convention.

@@ -181,15 +183,15 @@ export class ImaVidFramesController {
}

public setFrameRate(newFrameRate: number) {
if (newFrameRate > 24) {
throw new Error("max frame rate is 24");
if (newFrameRate > 60) {
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, is there a technical reason to cap at 60?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no... it's arbitrary based on local testing. but i'm hoping to set the right expectation by enforcing this cap. in ImaVid, we're on-the-fly fetching and streaming images and achieving higher fps than even 30 is kind of hard

@sashankaryal sashankaryal merged commit 74944ea into develop Jan 10, 2025
13 of 14 checks passed
@sashankaryal sashankaryal deleted the feat/imavid-configurable-frame-rate branch January 10, 2025 01:54
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants