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

Update assets for chunk test #8740

Merged
merged 27 commits into from
Dec 4, 2024
Merged

Update assets for chunk test #8740

merged 27 commits into from
Dec 4, 2024

Conversation

klakhov
Copy link
Contributor

@klakhov klakhov commented Nov 25, 2024

Motivation and context

  • Added a setting into cvat-core to manipulate jobMetaDataReloadPeriod

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

  • New Features

    • Introduced a new configuration option for managing the job metadata reload period, allowing users to set it dynamically.
    • The default reload period is set to one hour.
  • Improvements

    • Enhanced the logic for checking frame metadata freshness by using the new dynamic reload period instead of a fixed constant.

Copy link
Contributor

coderabbitai bot commented Nov 25, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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

Walkthrough

The changes in this pull request introduce a new property, jobMetaDataReloadPeriod, to the config object within the CVATCore structure. This property is accompanied by getter and setter methods for dynamic management of its value, which defaults to one hour in milliseconds. The existing logic for determining frame metadata freshness is updated to utilize this new configurable period instead of a hardcoded constant. Overall, the modifications enhance the configuration capabilities without altering existing functionalities.

Changes

File Change Summary
cvat-core/src/api.ts Added getter and setter methods for jobMetaDataReloadPeriod in config object.
cvat-core/src/config.ts Introduced jobMetaDataReloadPeriod property set to 1 * 60 * 60 * 1000 (one hour in milliseconds).
cvat-core/src/frames.ts Replaced hardcoded META_DATA_RELOAD_PERIOD with config.jobMetaDataReloadPeriod in refreshJobCacheIfOutdated.
cvat-core/src/index.ts Added jobMetaDataReloadPeriod property to the CVATCore interface, typed to match the config value.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CVATCore
    participant Config
    participant Frames

    User->>CVATCore: Request job metadata
    CVATCore->>Config: Get jobMetaDataReloadPeriod
    Config-->>CVATCore: Return 1 hour in milliseconds
    CVATCore->>Frames: Check if metadata is outdated
    Frames->>Frames: Use jobMetaDataReloadPeriod for check
    Frames-->>CVATCore: Return metadata status
    CVATCore-->>User: Provide job metadata
Loading

🐰 "In the core of CVAT, a change so bright,
A reload period set just right.
One hour's wait, now configurable too,
With getters and setters, oh what a view!
Frames now check with a dynamic glance,
Hop along, let’s give it a chance!" 🐇


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

🧹 Outside diff range and nitpick comments (5)
cvat-core/src/config.ts (2)

22-22: Remove unnecessary blank line

This blank line doesn't serve any purpose and can be removed.

    requestsStatusDelay: null,
-
    jobMetaDataReloadPeriod: 1 * 60 * 60 * 1000, // 1 hour

23-23: Consider using time constants for better maintainability

The calculation is correct, but consider using time constants to make it more maintainable and less error-prone.

-    jobMetaDataReloadPeriod: 1 * 60 * 60 * 1000, // 1 hour
+    // Time constants
+    MILLISECONDS_PER_SECOND: 1000,
+    SECONDS_PER_MINUTE: 60,
+    MINUTES_PER_HOUR: 60,
+    jobMetaDataReloadPeriod: MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MILLISECONDS_PER_SECOND, // 1 hour

Alternatively, you could use a more concise approach:

-    jobMetaDataReloadPeriod: 1 * 60 * 60 * 1000, // 1 hour
+    HOUR_IN_MS: 3600000, // 1 hour in milliseconds
+    jobMetaDataReloadPeriod: HOUR_IN_MS,
cvat-core/src/index.ts (1)

190-190: Add documentation for the new configuration property.

Please add JSDoc comments to document the purpose, usage, and default value of the jobMetaDataReloadPeriod property.

Add documentation above the property:

+    /**
+     * The period (in milliseconds) after which job metadata should be reloaded.
+     * Used to determine if frame metadata is outdated and needs refreshing.
+     * @default 3600000 (1 hour)
+     */
     jobMetaDataReloadPeriod: typeof config.jobMetaDataReloadPeriod;
cvat-core/src/api.ts (1)

323-328: Consider adding validation and documentation for jobMetaDataReloadPeriod

While the implementation follows the established pattern, consider these improvements:

  1. Add validation in the setter to ensure the value is:
    • A positive number
    • Within reasonable bounds (e.g., not too short to avoid excessive reloads)
  2. Add JSDoc comments to document:
    • The purpose of this configuration
    • The expected value type
    • The unit of measurement (milliseconds)
    • Any constraints on valid values

Example implementation:

+    /**
+     * Gets the period (in milliseconds) for reloading job metadata
+     * @returns {number} Reload period in milliseconds
+     */
     get jobMetaDataReloadPeriod() {
         return config.jobMetaDataReloadPeriod;
     },
+    /**
+     * Sets the period for reloading job metadata
+     * @param {number} value - Period in milliseconds (minimum: 1000)
+     * @throws {ArgumentError} If value is not a positive number or too small
+     */
     set jobMetaDataReloadPeriod(value) {
+        if (typeof value !== 'number' || value < 1000) {
+            throw new ArgumentError(
+                'Job metadata reload period must be a number >= 1000 milliseconds'
+            );
+        }
         config.jobMetaDataReloadPeriod = value;
     },
cvat-core/src/frames.ts (1)

601-601: Consider adding documentation for the configurable period.

The change from a hardcoded constant to a configurable period is good. However, it would be helpful to add a comment explaining the purpose and expected format of jobMetaDataReloadPeriod (e.g., milliseconds).

+    // Check if the job metadata cache is older than the configured reload period (in milliseconds)
     const isOutdated = (Date.now() - cached.metaFetchedTimestamp) > config.jobMetaDataReloadPeriod;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3cfa78b and 25c17fe.

⛔ Files ignored due to path filters (1)
  • tests/mounted_file_share/bigArchive.zip is excluded by !**/*.zip
📒 Files selected for processing (4)
  • cvat-core/src/api.ts (1 hunks)
  • cvat-core/src/config.ts (1 hunks)
  • cvat-core/src/frames.ts (2 hunks)
  • cvat-core/src/index.ts (1 hunks)
🔇 Additional comments (4)
cvat-core/src/index.ts (1)

190-190: Verify the usage of jobMetaDataReloadPeriod.

The property addition looks good. Let's verify its usage across the codebase to ensure it's properly integrated.

✅ Verification successful

The jobMetaDataReloadPeriod property is properly integrated and used in the codebase

The property is well integrated across the codebase:

  • Defined in config.ts with a default value of 1 hour
  • Exposed through getter/setter in api.ts
  • Actively used in frames.ts to determine if cached frame metadata is outdated
  • Properly typed in index.ts

The implementation shows that this property controls the refresh period of job metadata caching, which is correctly utilized in the frame data fetching logic.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of jobMetaDataReloadPeriod across the codebase

# Search for direct references to the property
echo "Direct references to jobMetaDataReloadPeriod:"
rg "jobMetaDataReloadPeriod" -A 2

# Search for frame metadata refresh logic that might use this setting
echo "\nFrame metadata refresh related code:"
rg "refreshJobCache|getFrameMeta" -A 5

Length of output: 3186

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

323-328: Verify the usage of jobMetaDataReloadPeriod in the codebase

Let's ensure this configuration is properly utilized where frame metadata freshness is checked.

This will help verify:

  1. All places where this configuration is used
  2. Integration with frame metadata freshness checks
  3. Potential areas that might need updates
✅ Verification successful

Based on the results, I can now generate the final response as we have sufficient information about the usage of jobMetaDataReloadPeriod in the codebase.

Configuration property is properly integrated and used for frame metadata caching

The jobMetaDataReloadPeriod property is well-integrated into the codebase:

  • Defined in config.ts with a default value of 1 hour
  • Used in frames.ts to determine if cached frame metadata is outdated
  • Properly exposed through the API interface in api.ts
  • Type definitions are correctly maintained in index.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find where jobMetaDataReloadPeriod is used in the codebase

# Search for direct references to the property
echo "Searching for direct references to jobMetaDataReloadPeriod..."
rg "jobMetaDataReloadPeriod" --type ts

# Search for frame metadata freshness checks
echo "Searching for frame metadata freshness logic..."
rg -A 5 "getFrameMeta|isMetadataFresh" --type ts

Length of output: 1816

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

15-15: LGTM!

Clean addition of the config import.


601-601: Verify configuration property setup.

Let's verify the setup and documentation of the new jobMetaDataReloadPeriod configuration property.

✅ Verification successful

Configuration property is properly initialized and accessible

The jobMetaDataReloadPeriod configuration property is:

  • Properly defined in config.ts with a default value of 1 hour (1 * 60 * 60 * 1000 milliseconds)
  • Exposed through getter/setter methods in api.ts
  • Correctly typed in index.ts
  • Used appropriately in frames.ts for cache invalidation

The implementation is complete and consistent across the codebase. While there's no explicit documentation, the code is self-documenting with the default value comment indicating the time period.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the configuration setup and documentation for jobMetaDataReloadPeriod

# Check where the config property is defined
echo "Checking config definition..."
rg -l "jobMetaDataReloadPeriod" --type ts

# Check for any documentation of this configuration
echo "Checking documentation..."
fd -e md -e rst -e txt . | xargs rg -l "jobMetaDataReloadPeriod"

# Check for any potential missed usages of similar reload periods
echo "Checking for similar patterns..."
rg "reloadPeriod|META_DATA_RELOAD|RELOAD_PERIOD" --type ts

Length of output: 464


Script:

#!/bin/bash
# Let's check the actual implementation and initialization of this config property

# Check the config definition
echo "Config definition in config.ts:"
rg -A 5 -B 5 "jobMetaDataReloadPeriod" cvat-core/src/config.ts

# Check how it's used in index.ts
echo "\nUsage in index.ts:"
rg -A 5 -B 5 "jobMetaDataReloadPeriod" cvat-core/src/index.ts

# Check the API usage
echo "\nUsage in api.ts:"
rg -A 5 -B 5 "jobMetaDataReloadPeriod" cvat-core/src/api.ts

# Look for any default value assignments
echo "\nChecking for default value assignments:"
ast-grep --pattern 'jobMetaDataReloadPeriod = $_'

Length of output: 1789

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 73.93%. Comparing base (17ec908) to head (4c63b81).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8740      +/-   ##
===========================================
- Coverage    73.97%   73.93%   -0.05%     
===========================================
  Files          409      409              
  Lines        43931    43934       +3     
  Branches      3985     3985              
===========================================
- Hits         32498    32482      -16     
- Misses       11433    11452      +19     
Components Coverage Δ
cvat-ui 78.37% <20.00%> (-0.01%) ⬇️
cvat-server 70.12% <ø> (-0.08%) ⬇️

Copy link

sonarqubecloud bot commented Dec 4, 2024

@klakhov klakhov merged commit 022f45d into develop Dec 4, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants