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

Fixed frames navigation and GT tracks displaying #8533

Merged
merged 10 commits into from
Oct 15, 2024
Merged

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented Oct 11, 2024

Motivation and context

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Resolved navigation issues related to keyframes in annotation jobs.
    • Fixed incorrect track display during review mode when frame steps were not set to 1.
  • New Features

    • Enhanced job metadata retrieval during job fetch operations.
    • Improved frame change validation to ensure accurate navigation based on specific frames.
  • Improvements

    • Updated frame navigation logic across various components for better accuracy and control.
    • Enhanced state management for annotations, including the addition of job metadata in the Redux store.

@bsekachev bsekachev requested a review from nmanovic as a code owner October 11, 2024 11:30
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes introduced in this pull request focus on enhancing navigation and frame management within the annotation application. Key updates include fixes for navigation by keyframes and track display issues, modifications to the FramesMetaData class to allow includedFrames to be null, and improvements in various components to validate frame changes based on specific target frames. Additionally, the state management in the Redux store has been refined to accommodate job metadata, enhancing overall functionality and accuracy.

Changes

File Change Summary
changelog.d/20241011_142625_sekachev.bs_fixed_navigation.md Added fixes for navigation by keyframes and track display during review mode.
cvat-core/src/frames.ts Updated includedFrames property to allow null, modified methods to handle this change, and updated documentation.
cvat-ui/src/actions/annotation-actions.ts Enhanced getJobAsync to include job metadata and updated frame change validation in changeFrameAsync.
cvat-ui/src/components/annotation-page/attribute-annotation-workspace/attribute-annotation-sidebar/attribute-annotation-sidebar.tsx Modified frame change logic in AttributeAnnotationSidebar to accept frame parameters.
cvat-ui/src/components/annotation-page/tag-annotation-workspace/tag-annotation-sidebar/tag-annotation-sidebar.tsx Updated onChangeFrame to pass frame parameter for validation.
cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx Changed changeFrame method to validate frame changes based on specific frame.
cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/objects-list.tsx Updated frame change logic in ObjectsListContainer to validate against specific frames.
cvat-ui/src/containers/annotation-page/top-bar/top-bar.tsx Modified frame navigation methods to validate against specific frames being accessed.
cvat-ui/src/reducers/annotation-reducer.ts Added meta property to job state for managing job metadata and refined state updates in various action cases.
cvat-ui/src/reducers/index.ts Introduced meta property in job interface for frame metadata.
cvat-ui/src/utils/filter-annotations.ts Updated filtering logic for ground truth annotations based on includedFrames.
cvat-ui/src/utils/is-able-to-change-frame.ts Modified function to accept a frame parameter and updated internal logic for frame validation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Actions
    participant Reducer
    participant State

    User->>UI: Request to change frame
    UI->>Actions: Validate frame change
    Actions->>Reducer: Update state with new frame
    Reducer->>State: Reflect new frame in state
    State-->>UI: Update UI with new frame
Loading

🐰 "In the land of frames so bright,
A hop, a skip, a change in sight.
With metadata now in tow,
Navigation's smooth, watch us go!
Keyframes dance, and tracks align,
In our world, all works just fine!" 🐇


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.

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

🧹 Outside diff range and nitpick comments (9)
changelog.d/20241011_142625_sekachev.bs_fixed_navigation.md (2)

3-4: Update the PR number in the changelog entry.

The changelog entry accurately describes the fix for incorrect navigation by keyframes. However, the PR number is missing and needs to be updated.

Please replace 'XXXX' with the actual PR number (8533) in the URL:

- (<https://github.com/cvat-ai/cvat/pull/XXXX>)
+ (<https://github.com/cvat-ai/cvat/pull/8533>)

5-6: Update the PR number in the changelog entry.

The changelog entry accurately describes the fix for incorrect display of tracks from ground truth jobs. However, the PR number is missing and needs to be updated.

Please replace 'XXXX' with the actual PR number (8533) in the URL:

- (<https://github.com/cvat-ai/cvat/pull/XXXX>)
+ (<https://github.com/cvat-ai/cvat/pull/8533>)
cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx (1)

214-217: LGTM! Consider adding error handling.

The change to isAbleToChangeFrame(frame) is a good improvement, as it now checks if the specific frame can be changed. This aligns well with the PR objective of fixing frame navigation issues.

Consider adding error handling or user feedback when isAbleToChangeFrame(frame) returns false. For example:

private changeFrame(frame: number): void {
    const { changeFrame } = this.props;
    if (isAbleToChangeFrame(frame)) {
        changeFrame(frame);
    } else {
        // Consider adding a user-friendly message or logging here
        console.warn(`Unable to change to frame ${frame}`);
    }
}

This would provide better feedback and potentially help with debugging if frame changes are unexpectedly blocked.

cvat-ui/src/components/annotation-page/tag-annotation-workspace/tag-annotation-sidebar/tag-annotation-sidebar.tsx (1)

209-211: Improved frame navigation logic, consider adding error handling.

The changes to the onChangeFrame function improve the frame navigation logic, especially when dealing with deleted frames. The use of jobInstance.frames.search provides more precise control over frame selection.

However, consider the following improvements:

  1. Add error handling for the jobInstance.frames.search call to gracefully handle any potential issues.
  2. Update any relevant tests to reflect the new asynchronous nature of this function.
  3. Consider adding a comment explaining the logic behind the frame search, particularly the use of the showDeletedFrames flag.

Here's a suggested implementation with error handling:

const onChangeFrame = async (): Promise<void> => {
    try {
        // Search for the next frame, skipping deleted frames if showDeletedFrames is false
        const frame = await jobInstance.frames.search(
            { notDeleted: !showDeletedFrames },
            frameNumber + 1,
            jobInstance.stopFrame,
        );

        if (frame !== null && isAbleToChangeFrame(frame)) {
            changeFrame(frame);
        }
    } catch (error) {
        // Handle the error appropriately, e.g., show a notification to the user
        console.error('Error while changing frame:', error);
        // You might want to add a user-friendly error message here
    }
};
cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/objects-list.tsx (1)

579-580: Improved frame navigation logic

The changes to the NEXT_KEY_FRAME and PREV_KEY_FRAME handlers enhance the frame navigation by checking if it's possible to change to a specific frame. This improvement aligns with the PR objective of fixing frames navigation.

Consider extracting the common logic for both handlers into a separate function to reduce code duplication:

const changeKeyFrame = (frameGetter: () => number | null) => {
  const state = activatedState();
  if (state && state.keyframes) {
    const frame = frameGetter();
    if (frame !== null && isAbleToChangeFrame(frame)) {
      changeFrame(frame);
    }
  }
};

// Usage:
NEXT_KEY_FRAME: (event: KeyboardEvent | undefined) => {
  preventDefault(event);
  changeKeyFrame(() => {
    const state = activatedState();
    return state?.keyframes?.next ?? null;
  });
},
PREV_KEY_FRAME: (event: KeyboardEvent | undefined) => {
  preventDefault(event);
  changeKeyFrame(() => {
    const state = activatedState();
    return state?.keyframes?.prev ?? null;
  });
},

This refactoring would improve code maintainability and reduce the risk of inconsistencies between the two handlers.

Also applies to: 589-590

cvat-ui/src/reducers/index.ts (1)

725-725: LGTM! Consider using optional chaining for null safety.

The addition of the meta property to the job object is a good enhancement for storing frame metadata. This change aligns well with the PR objectives of improving frame management and navigation.

To improve null safety when accessing this property, consider using optional chaining in the code that consumes this state. For example:

const frameMeta = state.annotation.job.meta?.someProperty;

This approach will help prevent potential null reference errors in the application.

cvat-core/src/frames.ts (1)

Line range hint 1-1024: Summary of changes and potential impact

The main changes in this file revolve around making the includedFrames property nullable and handling this new possibility in the getFrameIndex method. These changes appear to be consistent and well-implemented.

However, it's important to consider the following:

  1. The reason for allowing includedFrames to be null is not immediately clear from the code. It would be helpful to add a comment explaining the scenarios where this might occur.
  2. While the getFrameIndex method handles the null case, other parts of the codebase that use includedFrames might need to be updated to handle this new possibility.

Consider adding a brief comment near the includedFrames property declaration explaining why it can now be null. This will help future developers understand the design decision.

Additionally, it might be beneficial to run a thorough test suite that covers various scenarios with both null and non-null includedFrames to ensure the changes don't introduce any regressions.

cvat-ui/src/utils/is-able-to-change-frame.ts (2)

9-9: Update function documentation to include the new parameter

Since isAbleToChangeFrame now accepts an optional frame parameter, please update the function's documentation or JSDoc comments to reflect this change. This will help other developers understand the purpose and usage of the new parameter.


23-23: Fix typo in comment

There's a typo in the comment on line 23. The word "hovewer" should be corrected to "however" for clarity.

Apply this diff to correct the typo:

-            // hovewer includedFrames contains absolute values, so, we need to adjust it with the frameStep
+            // however includedFrames contains absolute values, so we need to adjust it with the frameStep
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 847b48c and 565573c.

📒 Files selected for processing (12)
  • changelog.d/20241011_142625_sekachev.bs_fixed_navigation.md (1 hunks)
  • cvat-core/src/frames.ts (1 hunks)
  • cvat-ui/src/actions/annotation-actions.ts (3 hunks)
  • cvat-ui/src/components/annotation-page/attribute-annotation-workspace/attribute-annotation-sidebar/attribute-annotation-sidebar.tsx (2 hunks)
  • cvat-ui/src/components/annotation-page/tag-annotation-workspace/tag-annotation-sidebar/tag-annotation-sidebar.tsx (1 hunks)
  • cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx (1 hunks)
  • cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/objects-list.tsx (2 hunks)
  • cvat-ui/src/containers/annotation-page/top-bar/top-bar.tsx (3 hunks)
  • cvat-ui/src/reducers/annotation-reducer.ts (3 hunks)
  • cvat-ui/src/reducers/index.ts (1 hunks)
  • cvat-ui/src/utils/filter-annotations.ts (1 hunks)
  • cvat-ui/src/utils/is-able-to-change-frame.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (18)
changelog.d/20241011_142625_sekachev.bs_fixed_navigation.md (1)

1-6: Excellent changelog entries, please double-check PR numbers.

The changelog entries are well-written, clear, and accurately reflect the fixes implemented in this PR. They align perfectly with the PR objectives of addressing issues related to frame navigation and GT tracks displaying.

Before merging, please ensure that:

  1. Both PR numbers are correctly updated to 8533.
  2. The descriptions accurately reflect all the changes made in the PR.

Run the following script to verify the PR number:

cvat-ui/src/utils/filter-annotations.ts (1)

35-39: Improved ground truth track filtering logic

The changes to the conditional logic for ground truth tracks are well-considered and appear to address potential issues with frame numbering. The additional check for includedFrames and the new calculation for frame inclusion should improve the accuracy of the filtering.

However, I have a few suggestions and questions:

  1. Consider adding a null check for frameStep to prevent potential runtime errors:
if (groundTruthJobFramesMeta.frameStep != null) {
  return groundTruthJobFramesMeta.includedFrames.includes(frame * groundTruthJobFramesMeta.frameStep);
} else {
  console.warn('frameStep is null or undefined');
  return false;
}
  1. Could you please clarify the concept of "absolute numeration" mentioned in the comment? This would help future developers understand the reasoning behind the frame * groundTruthJobFramesMeta.frameStep calculation.

To verify the usage of frameStep, let's run the following script:

cvat-ui/src/components/annotation-page/attribute-annotation-workspace/attribute-annotation-sidebar/attribute-annotation-sidebar.tsx (3)

319-321: Improved frame change validation for next keyframe

The modification to pass the frame parameter to isAbleToChangeFrame enhances the accuracy of frame navigation. This change ensures that the specific next keyframe is validated before changing the frame, which aligns with the PR's objective of fixing frame navigation issues.


329-331: Consistent frame change validation for previous keyframe

This change mirrors the improvement made to the next keyframe handler, ensuring consistent behavior for both forward and backward keyframe navigation. By passing the frame parameter to isAbleToChangeFrame, we maintain symmetry in the validation process for both directions.


Line range hint 319-331: Overall improvement in keyframe navigation

The changes made to both the next and previous keyframe handlers represent a focused and consistent improvement in frame navigation. By passing the specific frame to be validated in isAbleToChangeFrame, the code now ensures more accurate and reliable keyframe navigation. These modifications directly address the PR's objective of fixing frame navigation issues without introducing extensive changes to the existing codebase.

cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/objects-list.tsx (1)

Line range hint 1-624: Summary of changes

The modifications in this file focus on improving the frame navigation logic in the ObjectsListContainer component. The changes are minimal but impactful, addressing the PR objective of fixing frames navigation. The new implementation should prevent navigation to invalid frames, enhancing the overall user experience.

The rest of the file remains unchanged, maintaining the existing functionality of the component. The changes are well-integrated and don't introduce any apparent issues or inconsistencies with the existing code.

cvat-core/src/frames.ts (2)

Line range hint 220-234: LGTM: Proper handling of null includedFrames

The changes in the getFrameIndex method correctly handle the case where includedFrames is null. The fallback calculation using startFrame and frameStep is a good practice and aligns well with the type change of includedFrames.


47-47: Verify null checks for includedFrames

The type of includedFrames has been changed to allow null values. This change might have implications in other parts of the code where includedFrames is used.

To ensure this change doesn't introduce any null pointer exceptions, please run the following script to find all usages of includedFrames and verify that appropriate null checks are in place:

After running this script, please review each usage and ensure that null checks are added where necessary to handle cases where includedFrames might be null.

✅ Verification successful

IncludedFrames nullability is appropriately handled

All usages of includedFrames have been reviewed, and necessary null checks are in place to handle cases where includedFrames may be null, ensuring that the change does not introduce any null pointer exceptions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all usages of includedFrames
rg "includedFrames" --type ts

Length of output: 2357

cvat-ui/src/utils/is-able-to-change-frame.ts (2)

28-28: Confirm canvas.isAbleToChangeFrame() behaves as expected

Ensure that the method canvas.isAbleToChangeFrame() returns the correct boolean value under various conditions, and that it does not have side effects that could affect the application state.

Consider reviewing the implementation of canvas.isAbleToChangeFrame() to ensure its reliability.


24-25: Ensure meta.frameStep is defined and valid

When using meta.frameStep in the calculation, please verify that meta.frameStep is always defined and not zero to prevent potential errors or unexpected behavior.

You can run the following script to check for any occurrences where meta.frameStep might be undefined or zero:

✅ Verification successful

Verification Successful: meta.frameStep is properly defined and non-zero across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `meta.frameStep` is always defined and not zero.

# Test: Search for assignments to `meta.frameStep` and check its usage.
# Expected: All assignments should result in a defined, non-zero value.

rg --type ts --type js --context 5 'meta\.frameStep\s*=\s*(0|undefined|null)'

Length of output: 79

cvat-ui/src/containers/annotation-page/top-bar/top-bar.tsx (3)

Line range hint 398-406: Ensure isAbleToChangeFrame accepts frame parameter

Similarly, in the onNextFrame method, isAbleToChangeFrame is called with newFrame as an argument. Please verify that the function definition supports this parameter.


636-638: Ensure isAbleToChangeFrame accepts frame parameter

In the changeFrame method, isAbleToChangeFrame is now called with frame as an argument. Confirm that isAbleToChangeFrame is updated to accept this parameter.


Line range hint 370-378: Ensure isAbleToChangeFrame accepts frame parameter

In the updated code, isAbleToChangeFrame is called with newFrame as an argument. Please confirm that the isAbleToChangeFrame function is defined to accept a frame parameter and handles it appropriately.

To verify that isAbleToChangeFrame accepts a frame parameter, you can run the following script:

✅ Verification successful

Verification Successful: The isAbleToChangeFrame function is defined with a frame parameter in src/utils/is-able-to-change-frame.ts.

  • File: src/utils/is-able-to-change-frame.ts
  • Definition:
    export default function isAbleToChangeFrame(frame?: number): boolean {
        // function implementation
    }
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `isAbleToChangeFrame` function definition accepts a `frame` parameter.

# Expected: The function should be defined with a `frame` parameter.

rg --type typescript --multiline --pcre2 '^function isAbleToChangeFrame\(\s*frame' src/utils/is-able-to-change-frame.ts

Length of output: 156


Script:

#!/bin/bash
# Description: Verify that `isAbleToChangeFrame` function definition accepts a `frame` parameter using corrected ripgrep type.

# Expected: The function should be defined with a `frame` parameter.

rg --type ts --multiline --pcre2 '^function isAbleToChangeFrame\(\s*frame' src/utils/is-able-to-change-frame.ts

Length of output: 190


Script:

#!/bin/bash
# Description: Verify that `isAbleToChangeFrame` function definition accepts a `frame` parameter by targeting .ts files directly.

# Expected: The function should be defined with a `frame` parameter.

rg --multiline --pcre2 '^function isAbleToChangeFrame\(\s*frame' src/utils/is-able-to-change-frame.ts

Length of output: 180


Script:

#!/bin/bash
# Description: Verify that `isAbleToChangeFrame` function definition accepts a `frame` parameter using ast-grep.

# Expected: The function should be defined with a `frame` parameter.

ast-grep --lang typescript --pattern 'function isAbleToChangeFrame(frame: $_) { $$$ }' src/utils/is-able-to-change-frame.ts

Length of output: 209


Script:

#!/bin/bash
# Description: Search the entire codebase for the `isAbleToChangeFrame` function definition accepting a `frame` parameter using ripgrep.

# Expected: Output the file(s) and line(s) where the function is defined with a `frame` parameter.

rg --multiline --pcre2 '^function\s+isAbleToChangeFrame\(\s*frame\b' .

Length of output: 72


Script:

#!/bin/bash
# Description: Locate the `isAbleToChangeFrame` function definition with a `frame` parameter using ast-grep.

# Expected: Output the function definition details if it exists.

ast-grep --lang typescript --pattern 'function isAbleToChangeFrame(frame: $_) { $$$ }' .

Length of output: 90


Script:

#!/bin/bash
# Description: Search the entire codebase for any occurrences of `isAbleToChangeFrame` using ripgrep.

# Expected: Output all file paths and lines where `isAbleToChangeFrame` is mentioned.

rg 'isAbleToChangeFrame' .

Length of output: 4171


Script:

#!/bin/bash
# Description: Locate any definitions or references to `isAbleToChangeFrame` using ast-grep.

# Expected: Output details of the function or method definition if it exists.

ast-grep --lang typescript --pattern 'isAbleToChangeFrame($_) { $$$ }' .

Length of output: 528

cvat-ui/src/reducers/annotation-reducer.ts (3)

70-70: Initialize meta property in job state

Adding meta: null to the default job state initializes the meta property appropriately.


162-162: Include jobMeta in destructured action payload

Destructuring jobMeta from the action payload ensures it is available for updating the state.


210-210: Update job.meta with jobMeta

Assigning meta: jobMeta updates the job state with the new metadata received in the action payload.

cvat-ui/src/actions/annotation-actions.ts (2)

963-963: Ensure jobMeta is processed correctly in reducers and components

With jobMeta added to the payload in the GET_JOB_SUCCESS action, verify that reducers and any components consuming this payload handle jobMeta appropriately, including scenarios where it might be null due to a fetch error. This will prevent potential runtime errors if jobMeta is undefined or has unexpected values.

Run the following script to search for usages of jobMeta:


654-654: Verify that isAbleToChangeFrame accepts toFrame as an argument

The function isAbleToChangeFrame is now called with toFrame as an argument. Please ensure that isAbleToChangeFrame has been updated to accept this parameter and that all usages of this function have been revised accordingly.

Run the following script to verify the function definition:

@@ -914,6 +914,7 @@ export function getJobAsync({
}
}

const jobMeta = await cvat.frames.getMeta('job', job.id);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for cvat.frames.getMeta call

The call to cvat.frames.getMeta('job', job.id) does not include error handling. If this call fails, it could lead to unhandled exceptions or affect the application's stability. Consider wrapping this call in a try-catch block to handle potential errors gracefully.

Apply this diff to add error handling:

+    let jobMeta;
+    try {
+        jobMeta = await cvat.frames.getMeta('job', job.id);
+    } catch (error) {
+        // Handle the error appropriately, e.g., set jobMeta to null or dispatch an error action
+        jobMeta = null;
+        // Optionally log the error
+        console.error('Error fetching job metadata:', error);
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const jobMeta = await cvat.frames.getMeta('job', job.id);
let jobMeta;
try {
jobMeta = await cvat.frames.getMeta('job', job.id);
} catch (error) {
// Handle the error appropriately, e.g., set jobMeta to null or dispatch an error action
jobMeta = null;
// Optionally log the error
console.error('Error fetching job metadata:', error);
}

@bsekachev bsekachev requested a review from klakhov October 11, 2024 11:42
@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 93.02326% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.23%. Comparing base (12dac6d) to head (86db3f2).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8533      +/-   ##
===========================================
- Coverage    74.24%   74.23%   -0.02%     
===========================================
  Files          400      400              
  Lines        43207    43218      +11     
  Branches      3905     3909       +4     
===========================================
  Hits         32081    32081              
- Misses       11126    11137      +11     
Components Coverage Δ
cvat-ui 78.64% <93.75%> (-0.05%) ⬇️
cvat-server 70.47% <ø> (ø)

// includedFrames has absolute numeration of frames
// frame N actually corresponds to startFrame + N * frameStep in absolute numeration
const { frameStep, startFrame } = groundTruthJobFramesMeta;
const dataFrameNumber = frame * frameStep + startFrame;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we already have operations with transformation of relative/absolute frames here. Can we re-use it?

Also it seems they are duplicated inside of allocation table. Seems we need to refactor it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably you meant getDataFrameNumber as getDataStartFrame has another expression

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but it feels like we dont need multiple expressions for the same thing. The math behind it is the same. Its better to use something like:

const dataFrameNumber = getDataFrameNumber(meta, frame);

instead of writhing the transformation formula each time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Applied changes

// frame argument comes in relative job coordinates
// hovewer includedFrames contains absolute values, so, we need to adjust it with the frameStep and startFrame
frameInTheJob = meta.includedFrames ?
meta.includedFrames.includes(frame * meta.frameStep + meta.startFrame) :
Copy link
Contributor

Choose a reason for hiding this comment

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

The same comment as above

Copy link

@bsekachev bsekachev merged commit ac01fff into develop Oct 15, 2024
34 checks passed
@cvat-bot cvat-bot bot mentioned this pull request Oct 18, 2024
@bsekachev bsekachev deleted the bs/fixed_navigation branch October 24, 2024 05:15
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.

3 participants