-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Updated page with allocation report #8558
Conversation
WalkthroughThe changes involve a significant restructuring of the validation layout system for jobs and tasks within the application. The Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
🧹 Outside diff range and nitpick comments (11)
cvat-ui/src/components/quality-control/task-quality/summary.tsx (3)
12-12
: LGTM! Consider enhancing type clarity.The addition of the 'mode' property to the Props interface improves type safety and aligns with the new validation context. Good job!
For improved clarity, consider using a more descriptive type alias:
type ValidationMode = 'ground_truth' | 'honeypot';This would make the code more self-documenting and easier to understand at a glance.
27-31
: LGTM! Consider adding ARIA labels for improved accessibility.The conditional rendering of the validation mode enhances the UI by providing context-specific information. The implementation is clean and consistent with the existing code style.
To improve accessibility, consider adding ARIA labels to the Text components:
<Text aria-label="Validation mode label"> Validation mode: </Text> {' '} <Text strong aria-label="Validation mode value"> {mode === 'gt' ? 'Ground Truth' : 'Honeypots'} </Text>This would provide better context for screen readers.
43-49
: LGTM! Consider consistent naming for CSS classes.The addition of the excluded validation frames information enhances the comprehensiveness of the summary. The implementation is consistent with other elements and correctly uses the 'excludedCount' prop.
For consistency with other class names, consider updating the CSS class name:
- <Col span={12} className='cvat-allocation-summary-excluded'> + <Col span={12} className='cvat-allocation-summary-excluded-frames'>This would align with the naming pattern used for other elements (e.g., 'cvat-allocation-summary-active').
cvat-ui/src/cvat-core-wrapper.ts (1)
38-38
: Overall assessment: Changes look good and align with PR objectives.The modifications to this file are minimal and focused on restructuring the validation layout system. The changes are consistent with the PR objectives and the AI-generated summary. The new structure with
JobValidationLayout
andTaskValidationLayout
should provide more flexibility and specificity in handling validations for jobs and tasks.To ensure a smooth transition:
- Verify that all usages of the old
ValidationLayout
have been updated throughout the codebase.- Consider updating the documentation to reflect these changes in the validation system.
- Ensure that any affected tests are updated to use the new layout structures.
Also applies to: 109-110
cvat-core/src/server-response-types.ts (1)
527-530
: LGTM. Consider adding documentation.The
SerializedJobValidationLayout
interface looks good. It provides a flexible structure for job validation layout with honeypot-related properties.Consider adding JSDoc comments to explain the purpose of this interface and its properties, especially the concept of honeypot frames in the context of job validation. This will improve code maintainability and help other developers understand the intended use of this interface.
cvat-core/src/api.ts (1)
29-29
: Summary: Validation layout refactoring improves modularityThe changes in this file are part of a larger refactoring effort to separate job and task validation layouts. This separation likely improves the modularity and maintainability of the codebase. The modifications are consistent and well-structured, with no apparent issues in the implementation.
Key points:
- Import statement updated to use named imports for specific validation layouts.
- New
JobValidationLayout
andTaskValidationLayout
classes added to theclasses
object.These changes should provide more flexibility and clarity when working with validation layouts in different contexts (jobs vs. tasks) throughout the CVAT application.
As this refactoring progresses, consider the following:
- Ensure all usages of the old
ValidationLayout
class are updated throughout the codebase.- Update any documentation or API references to reflect these changes.
- If not already done, consider adding or updating unit tests to cover the new validation layout classes and their usage.
Also applies to: 430-431
cvat-core/src/session.ts (2)
689-692
: LGTM: Job validation layout return type updatedThe
validationLayout
method now correctly returns aPromise<JobValidationLayout | null>
instead of the genericValidationLayout
. This change improves type safety and clarity.Consider updating the JSDoc comment for this method to reflect the new return type:
/** * Retrieves the validation layout for the job. * @returns A promise that resolves to a JobValidationLayout or null if not available. */ async validationLayout(): Promise<JobValidationLayout | null> { // ... existing implementation ... }
1189-1192
: LGTM: Task validation layout return type updatedThe
validationLayout
method now correctly returns aPromise<TaskValidationLayout | null>
instead of the genericValidationLayout
. This change improves type safety and clarity, and is consistent with the changes made to theJob
class.Consider updating the JSDoc comment for this method to reflect the new return type:
/** * Retrieves the validation layout for the task. * @returns A promise that resolves to a TaskValidationLayout or null if not available. */ async validationLayout(): Promise<TaskValidationLayout | null> { // ... existing implementation ... }cvat-core/src/server-proxy.ts (2)
Line range hint
1386-1391
: Consider improving type safety in surrounding functionsWhile reviewing the
validationLayout
function changes, I noticed that some surrounding functions in this file use theany
type. For better type safety and code maintainability, consider replacingany
with more specific types where possible.For example, in the
getUsers
function:async function getUsers(filter = { page_size: 'all' }): Promise<SerializedUser[]> { // ... }You could create a specific type for the filter object:
type UserFilter = { page_size: 'all' | number; // Add other possible filter properties }; async function getUsers(filter: UserFilter = { page_size: 'all' }): Promise<SerializedUser[]> { // ... }This approach would provide better type checking and autocompletion for function arguments.
Line range hint
1-1391
: Address TODO comments in the codebaseThere are several TODO comments throughout the file that might need attention. For example:
- Line 1075:
// TODO: rewrite server logic, now it returns 202, 201 codes, but we need RQ statuses and details
These TODO items should be addressed to improve the codebase and remove technical debt. Consider creating issues in your project management system to track and prioritize these tasks.
cvat-ui/src/components/quality-control/quality-control-page.tsx (1)
Line range hint
347-375
: Ensure 'Settings' tab is accessible even without a ground truth jobCurrently, the 'Settings' tab is added only if
gtJobInstance
andgtJobMeta
are available. This restricts users from accessing the quality settings when no ground truth job exists. If the intention is to allow configuration of quality settings regardless of the ground truth job's presence, consider restructuring the conditions.Apply this diff to adjust the placement of the 'Settings' tab:
if (instance && settingsInitialized) { // Existing code for backNavigation and title... const tabsItems: NonNullable<TabsProps['items']>[0][] = []; tabsItems.push({ key: 'overview', label: 'Overview', children: ( <QualityOverviewTab task={instance} targetMetric={targetMetric} /> ), }); + tabsItems.push({ + key: 'settings', + label: 'Settings', + children: ( + <QualitySettingsTab + fetching={qualitySettingsFetching} + qualitySettings={qualitySettings} + setQualitySettings={onSaveQualitySettings} + /> + ), + }); if (gtJobInstance && gtJobMeta && validationLayout) { tabsItems.push({ key: 'management', label: 'Management', children: ( <QualityManagementTab task={instance} gtJobId={gtJobInstance.id} gtJobMeta={gtJobMeta} validationLayout={validationLayout} onDeleteFrames={onDeleteFrames} onRestoreFrames={onRestoreFrames} fetching={fetching} /> ), }); } tabs = ( <Tabs type='card' activeKey={activeTab} defaultActiveKey='Overview' onChange={onTabKeyChange} className='cvat-task-control-tabs' items={tabsItems} /> ); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (13)
- cvat-core/src/api.ts (2 hunks)
- cvat-core/src/index.ts (2 hunks)
- cvat-core/src/server-proxy.ts (2 hunks)
- cvat-core/src/server-response-types.ts (1 hunks)
- cvat-core/src/session-implementation.ts (4 hunks)
- cvat-core/src/session.ts (3 hunks)
- cvat-core/src/validation-layout.ts (2 hunks)
- cvat-ui/src/components/quality-control/quality-control-page.tsx (10 hunks)
- cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx (5 hunks)
- cvat-ui/src/components/quality-control/task-quality/quality-magement-tab.tsx (3 hunks)
- cvat-ui/src/components/quality-control/task-quality/summary.tsx (1 hunks)
- cvat-ui/src/cvat-core-wrapper.ts (2 hunks)
- cvat-ui/src/reducers/index.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (35)
cvat-ui/src/components/quality-control/task-quality/summary.tsx (4)
19-21
: LGTM! Proper implementation of the new 'mode' property.The destructuring of the 'mode' property from props is correctly implemented and maintains consistency with the existing code style.
36-36
: LGTM! Improved clarity in UI text.The update from "Total count:" to "Total validation frames:" enhances clarity and provides better context for users. This change aligns well with the overall purpose of the component.
52-52
: LGTM! Consistent improvement in label clarity.The update from "Active count:" to "Active validation frames:" is consistent with other label changes in the component. This change enhances clarity and specificity for users.
Line range hint
1-72
: Overall, excellent improvements to the SummaryComponent!The changes in this file significantly enhance the clarity and functionality of the component. The introduction of the 'mode' property and the updated UI text provide better context for users regarding validation frames. The code maintains consistency with the existing style and React best practices.
Key improvements:
- Added type safety with the new 'mode' property
- Enhanced UI clarity with more descriptive labels
- Introduced conditional rendering for different validation modes
- Provided more comprehensive information about validation frames
These changes align well with the PR objectives and improve the overall user experience. Great job!
cvat-ui/src/cvat-core-wrapper.ts (1)
109-110
: LGTM! Export changes are consistent.The addition of
JobValidationLayout
andTaskValidationLayout
to the export list is consistent with the import changes and maintains the module's structure. This change makes these new layouts available for use in other parts of the application.cvat-core/src/index.ts (2)
35-35
: LGTM: Import statement updated to reflect new validation layout types.The change from a single
ValidationLayout
import to separateJobValidationLayout
andTaskValidationLayout
imports is a good improvement. This update likely enhances type safety and provides better clarity in distinguishing between job and task validation layouts throughout the codebase.
Line range hint
1-226
: Overall assessment: Changes improve type safety and clarity.The modifications to
cvat-core/src/index.ts
are well-implemented and align with the PR objectives. The introduction of separateJobValidationLayout
andTaskValidationLayout
types enhances type safety and provides better clarity in distinguishing between job and task validation layouts. These changes should contribute to improved code maintainability and reduced potential for type-related errors.cvat-core/src/server-response-types.ts (1)
533-537
: LGTM. Please add documentation and clarify themode
property.The
SerializedTaskValidationLayout
interface looks good. It extendsSerializedJobValidationLayout
and adds task-specific properties.
- Add JSDoc comments to explain the purpose of this interface and its properties.
- Clarify the meaning and implications of the
mode
property values ('gt', 'gt_pool', null). What do these modes represent in the context of task validation?- Consider using more descriptive names for
validation_frames
anddisabled_frames
if possible, or add comments explaining their purpose.To ensure consistent usage of the new
mode
property, let's check for its implementation across the codebase:✅ Verification successful
Verification Successful
The
mode
property is correctly implemented and used as described in theSerializedTaskValidationLayout
interface.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usage of 'mode' property in the context of task validation rg --type typescript --type javascript -i "mode.*['\"]gt['\"]|mode.*['\"]gt_pool['\"]|mode\s*:\s*null" -g '!*test*'Length of output: 160
Script:
#!/bin/bash # Search for usage of 'mode' property in TypeScript and JavaScript files rg -g "*.ts" -g "*.js" -i "mode\s*[:=]\s*['\"]gt['\"]|mode\s*[:=]\s*['\"]gt_pool['\"]|mode\s*[:=]\s*null" -A 2 -- '!*test*'Length of output: 181
Script:
#!/bin/bash # Search for usage of 'mode' property in TypeScript and JavaScript files, excluding test files rg -g "*.ts" -g "*.js" -g "!*test*" -i "mode\s*[:=]\s*['\"]gt['\"]|mode\s*[:=]\s*['\"]gt_pool['\"]|mode\s*[:=]\s*null"Length of output: 262
cvat-core/src/api.ts (2)
430-431
: LGTM: New validation layout classes added to theclasses
object.The addition of
JobValidationLayout
andTaskValidationLayout
to theclasses
object aligns with the import changes and makes these new classes available throughout the CVAT application. This is a good step towards more modular and specific validation layouts.However, we should verify the removal of the old
ValidationLayout
class:#!/bin/bash # Description: Verify the removal of the old ValidationLayout class # Test 1: Check if ValidationLayout is still present in this file grep -n "ValidationLayout" cvat-core/src/api.ts # Test 2: Search for any remaining usage of ValidationLayout in the codebase rg "ValidationLayout" --type tsIf Test 1 returns any results or if Test 2 finds usages outside of import statements or comments, we may need to address those occurrences to complete the refactoring process.
29-29
: LGTM: Import statement updated to reflect modular validation layouts.The change from a default import to named imports for
JobValidationLayout
andTaskValidationLayout
suggests a good refactoring of thevalidation-layout
module. This separation likely improves modularity and maintainability.To ensure consistency, let's verify the structure of the
validation-layout
module:✅ Verification successful
✅ Verified: Validation-layout module structure confirmed.
The
validation-layout.ts
file correctly exportsJobValidationLayout
andTaskValidationLayout
classes. All import statements and usages across the codebase are consistent and properly implemented.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the structure of the validation-layout module # Test: Check if the validation-layout file exists and exports the correct classes cat cvat-core/src/validation-layout.tsLength of output: 5851
cvat-ui/src/reducers/index.ts (1)
Line range hint
1-1037
: Overall assessment: Positive change with minimal impactThe modification in this file is limited to a single type change in the
AnnotationState
interface. This change fromValidationLayout
toJobValidationLayout
improves type specificity and is consistent with the reported changes in import statements. The rest of the file, which defines various interfaces and enums for the application state, remains unchanged. This isolated change suggests a focused refactoring effort to improve job-related type handling.To ensure a smooth transition, please make sure that:
- All related components and functions using the
AnnotationState
interface are updated to work with the newJobValidationLayout
type.- Any serialization/deserialization logic handling this data is adjusted if necessary.
- Unit tests covering this part of the state are updated to reflect the new type.
cvat-core/src/session.ts (2)
31-31
: LGTM: Import statement updated correctlyThe import statement has been updated to include
JobValidationLayout
andTaskValidationLayout
instead of the genericValidationLayout
. This change aligns with the modifications in theJob
andTask
classes, providing more specific validation layout types.
31-31
: Summary: Improved type safety for validation layoutsThe changes in this file represent a cohesive update to the validation layout system:
- The import statement now includes specific
JobValidationLayout
andTaskValidationLayout
types.- The
Job
class'svalidationLayout
method now returnsPromise<JobValidationLayout | null>
.- The
Task
class'svalidationLayout
method now returnsPromise<TaskValidationLayout | null>
.These changes improve type safety and make the code more self-documenting. They should help prevent type-related errors and make it easier for developers to understand the expected structure of validation layouts for jobs and tasks.
Also applies to: 689-692, 1189-1192
cvat-core/src/server-proxy.ts (2)
1387-1387
: Update function return type to use union typeThe return type of the
validationLayout
function has been updated to use a union typeSerializedJobValidationLayout | SerializedTaskValidationLayout
. This change improves type safety by specifying that the function can return either a job validation layout or a task validation layout.
Line range hint
1-1391
: Summary of review
- The changes to the
validationLayout
function improve type safety by using a union type for the return value.- Some surrounding functions could benefit from improved type safety by replacing
any
types with more specific types.- There are TODO comments throughout the file that should be addressed to reduce technical debt.
Overall, the changes are good, but there's room for further improvements in the codebase.
cvat-ui/src/components/quality-control/task-quality/quality-magement-tab.tsx (2)
9-9
: Import statement updated correctlyThe
TaskValidationLayout
has been properly imported from'cvat-core-wrapper'
.
56-56
: ConfirmAllocationTable
component acceptsgtJobId
Ensure that the
AllocationTable
component has been updated to acceptgtJobId
instead ofgtJob
. Verify that all internal references withinAllocationTable
have been adjusted accordingly to prevent any breaking changes.Run the following script to check for references to
gtJob
inAllocationTable
:cvat-core/src/validation-layout.ts (11)
5-5
: Import statements are correctThe required serialized types are correctly imported from
'server-response-types'
.
13-16
: Constructor initializes fields correctlyThe constructor properly initializes the private fields, using the nullish coalescing operator to handle undefined values.
19-21
: Getter for honeypotCount is implemented correctlyThe
honeypotCount
getter accurately returns the value of#honeypotCount
.
23-25
: Getter for honeypotFrames is implemented correctlyThe
honeypotFrames
getter returns a copy of the#honeypotFrames
array, preventing external mutations.
27-29
: Getter for honeypotRealFrames is implemented correctlyThe
honeypotRealFrames
getter returns a copy of the#honeypotRealFrames
array, ensuring immutability from outside the class.
Line range hint
37-49
: Implementation of getRealFrame is correctly definedThe
Object.defineProperties
method is used to define theimplementation
ofgetRealFrame
, which seems consistent with the plugin architecture used in the project.
57-62
: Constructor correctly initializes additional fieldsThe constructor of
TaskValidationLayout
correctly calls the parent constructor and initializes the new private fields introduced in this subclass.
64-66
: Getter for mode is implemented correctlyThe
mode
getter returns the value of#mode
, providing access to the task's validation mode.
68-70
: Getter for validationFrames is implemented correctlyThe
validationFrames
getter returns a copy of the#validationFrames
array, which ensures that the original array remains unmodified.
72-74
: Getter for disabledFrames is implemented correctlyThe
disabledFrames
getter returns a copy of the#disabledFrames
array, maintaining the integrity of the class's internal state.
32-34
: Verify the usage of PluginRegistry.apiWrapper.callIn the
getRealFrame
method, thePluginRegistry.apiWrapper.call
is used withJobValidationLayout.prototype.getRealFrame
. Ensure that this usage aligns with the project's plugin architecture and that the method references are correctly set up.Run the following script to check the implementation and usage:
cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx (5)
17-17
: Import statement updated correctlyThe addition of
TaskValidationLayout
to the import statement ensures that the component has access to the necessary type definitions.
23-25
: Props interface updated appropriatelyThe
Props
interface now includesgtJobId
andvalidationLayout
, reflecting the changes in data handling. This modification aligns with the updated structure of the component's requirements.
38-38
: Destructuring props includes new propertiesDestructuring
gtJobId
andvalidationLayout
fromprops
is correct and matches the updatedProps
interface.
70-70
: Navigation update uses correct job IDThe
history.push
call correctly utilizesgtJobId
to navigate to the appropriate job frame.
91-91
: Navigation handler updated appropriatelyThe
onClick
handler now correctly referencesgtJobId
andrecord.frame
to navigate, ensuring consistency with the updated props.cvat-core/src/session-implementation.ts (2)
30-33
: Imports of Serialized Validation Layouts are CorrectThe added imports of
SerializedJobValidationLayout
andSerializedTaskValidationLayout
from'./server-response-types'
are appropriate and necessary for handling the new validation layouts in the code.
43-43
: Imports of Validation Layout Classes are CorrectThe imports of
JobValidationLayout
andTaskValidationLayout
from'./validation-layout'
are correctly added and align with their usage in thevalidationLayoutImplementation
methods.
@@ -35,7 +35,7 @@ import Comment from 'cvat-core/src/comment'; | |||
import User from 'cvat-core/src/user'; | |||
import Organization, { Membership, Invitation } from 'cvat-core/src/organization'; | |||
import AnnotationGuide from 'cvat-core/src/guide'; | |||
import ValidationLayout from 'cvat-core/src/validation-layout'; | |||
import { JobValidationLayout, TaskValidationLayout } from 'cvat-core/src/validation-layout'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
ValidationLayout is still used in multiple files.
The refactoring to JobValidationLayout
and TaskValidationLayout
did not completely replace all instances of ValidationLayout
. Please update all remaining usages to ensure consistency and prevent potential issues.
- cvat-ui/src/cvat-core-wrapper.ts
- cvat-ui/src/reducers/index.ts
- cvat-ui/src/components/quality-control/quality-control-page.tsx
- cvat-ui/src/components/quality-control/task-quality/quality-magement-tab.tsx
- cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx
- cvat-ui/src/actions/annotation-actions.ts
- cvat-core/src/validation-layout.ts
- cvat-core/src/session.ts
- cvat-core/src/session-implementation.ts
- cvat-core/src/server-proxy.ts
- cvat-core/src/index.ts
- cvat-core/src/api.ts
🔗 Analysis chain
LGTM! Verify usage of new validation layouts.
The import change from a single ValidationLayout
to specific JobValidationLayout
and TaskValidationLayout
aligns with the restructuring mentioned in the PR summary. This change improves granularity and allows for more specific handling of job and task validations.
To ensure consistency across the codebase, please run the following script to verify the usage of these new layouts:
Update: Adjusted the search to target .ts
and .tsx
files since typescript
is not a recognized file type in the current environment. Please run the following updated script to verify the usage of the new validation layouts:
[/run_scripts]
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the usage of JobValidationLayout and TaskValidationLayout
# Test: Search for ValidationLayout usage
echo "Searching for any remaining ValidationLayout usage:"
rg --type typescript "ValidationLayout"
# Test: Search for JobValidationLayout and TaskValidationLayout usage
echo "Searching for JobValidationLayout and TaskValidationLayout usage:"
rg --type typescript "JobValidationLayout|TaskValidationLayout"
Length of output: 429
Script:
#!/bin/bash
# Description: Verify the usage of JobValidationLayout and TaskValidationLayout
# Test: Search for any remaining ValidationLayout usage in .ts and .tsx files
echo "Searching for any remaining ValidationLayout usage:"
rg "ValidationLayout" --glob "*.ts" --glob "*.tsx"
# Test: Search for JobValidationLayout and TaskValidationLayout usage in .ts and .tsx files
echo "Searching for JobValidationLayout and TaskValidationLayout usage:"
rg "JobValidationLayout|TaskValidationLayout" --glob "*.ts" --glob "*.tsx"
Length of output: 11147
JobValidationLayout: typeof JobValidationLayout; | ||
TaskValidationLayout: typeof TaskValidationLayout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
ValidationLayout
Usages Detected
The verification script identified remaining usages of the old ValidationLayout
type in the following files:
cvat-ui/src/actions/annotation-actions.ts
cvat-core/src/actions/annotation-actions.ts
Please update these instances to use JobValidationLayout
and TaskValidationLayout
instead of the deprecated ValidationLayout
to maintain consistency and ensure type safety throughout the codebase.
🔗 Analysis chain
LGTM: New validation layout types added to classes
.
The addition of JobValidationLayout
and TaskValidationLayout
to the classes
section is consistent with the import changes and represents a good improvement in type specificity. This change should enhance type safety and code clarity when working with validation layouts for jobs and tasks.
To ensure this change is consistently applied throughout the codebase, please run the following verification script:
Action Required: Update verification scripts due to errors in initial execution.
Action Required: Correct the verification scripts to address ripgrep
errors.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining usage of the old ValidationLayout type and verify the usage of new types.
# Test 1: Check for any remaining usage of ValidationLayout
echo "Checking for any remaining usage of ValidationLayout:"
rg --type typescript "ValidationLayout(?!.*JobValidationLayout.*TaskValidationLayout)" -g '!cvat-core/src/index.ts'
# Test 2: Verify the usage of new JobValidationLayout and TaskValidationLayout types
echo "Verifying usage of new JobValidationLayout and TaskValidationLayout types:"
rg --type typescript "JobValidationLayout|TaskValidationLayout"
# Note: Review the output to ensure that ValidationLayout has been replaced everywhere necessary,
# and that JobValidationLayout and TaskValidationLayout are being used appropriately.
Length of output: 777
Script:
#!/bin/bash
# Description: Check for any remaining usage of the old ValidationLayout type and verify the usage of new types.
# Test 1: Check for any remaining usage of ValidationLayout using PCRE2 to support look-around
echo "Checking for any remaining usage of ValidationLayout:"
rg --pcre2 --type typescript "ValidationLayout(?!.*JobValidationLayout.*TaskValidationLayout)" -g '!cvat-core/src/index.ts'
# Test 2: Verify the usage of new JobValidationLayout and TaskValidationLayout types using file extensions
echo "Verifying usage of new JobValidationLayout and TaskValidationLayout types:"
rg "JobValidationLayout|TaskValidationLayout" -g '*.ts' -g '*.tsx'
# Note: Review the output to ensure that ValidationLayout has been replaced everywhere necessary,
# and that JobValidationLayout and TaskValidationLayout are being used appropriately.
Length of output: 5658
Script:
#!/bin/bash
# Description: Check for any remaining usage of the old ValidationLayout type and verify the usage of new types.
# Test 1: Check for any remaining usage of ValidationLayout using PCRE2 to support look-around
echo "Checking for any remaining usage of ValidationLayout:"
rg --pcre2 "ValidationLayout(?!.*JobValidationLayout.*TaskValidationLayout)" -g '*.ts' -g '*.tsx' -g '!cvat-core/src/index.ts'
# Test 2: Verify the usage of new JobValidationLayout and TaskValidationLayout types using file extensions
echo "Verifying usage of new JobValidationLayout and TaskValidationLayout types:"
rg "JobValidationLayout|TaskValidationLayout" -g '*.ts' -g '*.tsx'
# Note: Review the output to ensure that ValidationLayout has been replaced everywhere necessary,
# and that JobValidationLayout and TaskValidationLayout are being used appropriately.
Length of output: 10973
@@ -730,7 +730,7 @@ export interface AnnotationState { | |||
defaultPointsCount: number | null; | |||
}; | |||
groundTruthInfo: { | |||
validationLayout: ValidationLayout | null; | |||
validationLayout: JobValidationLayout | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
ValidationLayout Usage Detected in Multiple Files
Several remaining usages of ValidationLayout
were found across the codebase:
cvat-ui/src/actions/annotation-actions.ts
:validationLayout: ValidationLayout | null;
cvat-ui/src/cvat-core-wrapper.ts
: Imports and usage ofValidationLayout
cvat-ui/src/components/quality-control/quality-control-page.tsx
: Multiple instances ofValidationLayout
cvat-ui/src/components/quality-control/task-quality/quality-magement-tab.tsx
: Import and usage ofValidationLayout
cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx
: Import and usage ofValidationLayout
cvat-core/src/validation-layout.ts
: Definitions related toValidationLayout
cvat-core/src/api.ts
: Imports ofValidationLayout
cvat-core/src/session-implementation.ts
: Usage ofValidationLayout
cvat-core/src/index.ts
: Imports and definitions involvingValidationLayout
cvat-core/src/session.ts
: Methods returningValidationLayout
Please review these occurrences to ensure they align with the recent type changes and refactoring efforts.
🔗 Analysis chain
LGTM! Consider verifying usage across the codebase.
The change from ValidationLayout
to JobValidationLayout
improves type specificity for job-related validation layouts. This is a good improvement for type safety and code clarity.
To ensure this change doesn't introduce any unintended side effects, please run the following script to check for any remaining usage of ValidationLayout
in the codebase:
If the script returns any results, please review those occurrences to ensure they are updated accordingly.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining usage of ValidationLayout in the codebase
# Search for ValidationLayout in TypeScript and JavaScript files
echo "Searching for ValidationLayout usage:"
rg --type-add 'script:*.{ts,tsx,js,jsx}' -t script 'ValidationLayout'
# Search for imports of ValidationLayout
echo "\nSearching for ValidationLayout imports:"
rg --type-add 'script:*.{ts,tsx,js,jsx}' -t script 'import.*ValidationLayout'
Length of output: 6947
@@ -41,6 +42,7 @@ function QualityManagementTab(props: Readonly<Props>): JSX.Element { | |||
<Row> | |||
<Col span={24}> | |||
<SummaryComponent | |||
mode={validationLayout.mode} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass mode
prop safely to SummaryComponent
Ensure that validationLayout.mode
is defined before passing it to SummaryComponent
to avoid potential undefined property access.
Consider modifying the code as follows:
- mode={validationLayout.mode}
+ mode={validationLayout?.mode || 'default'}
Replace 'default'
with an appropriate default mode if necessary.
📝 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.
mode={validationLayout.mode} | |
mode={validationLayout?.mode || 'default'} |
const totalCount = validationLayout.validationFrames.length; | ||
const excludedCount = validationLayout.disabledFrames.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure safe access to validationLayout
properties
To prevent potential runtime errors, consider adding null or undefined checks for validationLayout
before accessing its properties validationFrames
and disabledFrames
. This will ensure the component handles cases where validationLayout
might not be provided.
Apply this diff to include safe access:
- const totalCount = validationLayout.validationFrames.length;
- const excludedCount = validationLayout.disabledFrames.length;
+ const totalCount = validationLayout?.validationFrames?.length || 0;
+ const excludedCount = validationLayout?.disabledFrames?.length || 0;
📝 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.
const totalCount = validationLayout.validationFrames.length; | |
const excludedCount = validationLayout.disabledFrames.length; | |
const totalCount = validationLayout?.validationFrames?.length || 0; | |
const excludedCount = validationLayout?.disabledFrames?.length || 0; |
export class TaskValidationLayout extends JobValidationLayout { | ||
#mode: TaskValidationLayout['mode']; | ||
#validationFrames: TaskValidationLayout['validationFrames']; | ||
#disabledFrames: TaskValidationLayout['disabledFrames']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid circular type references in TaskValidationLayout's private fields
Similar to JobValidationLayout
, the private fields in TaskValidationLayout
are defined using types that reference themselves, which can cause circular references.
Consider declaring the types explicitly:
export class TaskValidationLayout extends JobValidationLayout {
- #mode: TaskValidationLayout['mode'];
- #validationFrames: TaskValidationLayout['validationFrames'];
- #disabledFrames: TaskValidationLayout['disabledFrames'];
+ #mode: NonNullable<SerializedTaskValidationLayout['mode']>;
+ #validationFrames: number[];
+ #disabledFrames: number[];
📝 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.
export class TaskValidationLayout extends JobValidationLayout { | |
#mode: TaskValidationLayout['mode']; | |
#validationFrames: TaskValidationLayout['validationFrames']; | |
#disabledFrames: TaskValidationLayout['disabledFrames']; | |
export class TaskValidationLayout extends JobValidationLayout { | |
#mode: NonNullable<SerializedTaskValidationLayout['mode']>; | |
#validationFrames: number[]; | |
#disabledFrames: number[]; |
const { disabledFrames } = validationLayout; | ||
const data = validationLayout.validationFrames.map((frame: number, index: number) => ({ | ||
key: frame, | ||
frame, | ||
name: gtJobMeta.frames[index]?.name ?? gtJobMeta.frames[0].name, | ||
active: !disabledFrames.includes(frame), | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle potential undefined or mismatched frame data
In the data mapping function, there is a possibility of gtJobMeta.frames[index]
being undefined
if gtJobMeta.frames
doesn't have a frame at the given index. Accessing .name
on undefined
will result in a runtime error. Similarly, accessing gtJobMeta.frames[0]
assumes that there is at least one frame available.
Consider adding a check to ensure that gtJobMeta.frames
contains frames at the expected indices. You can provide a default value or handle cases where frames are missing.
Apply this diff to handle potential undefined frames:
name: gtJobMeta.frames[index]?.name
- ?? gtJobMeta.frames[0].name,
+ ?? (gtJobMeta.frames[0]?.name ?? 'Unnamed Frame'),
This change adds an extra layer of safety by checking if gtJobMeta.frames[0]
exists before accessing .name
, and provides a fallback 'Unnamed Frame'
if neither is available.
📝 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.
const { disabledFrames } = validationLayout; | |
const data = validationLayout.validationFrames.map((frame: number, index: number) => ({ | |
key: frame, | |
frame, | |
name: gtJobMeta.frames[index]?.name ?? gtJobMeta.frames[0].name, | |
active: !disabledFrames.includes(frame), | |
})); | |
const { disabledFrames } = validationLayout; | |
const data = validationLayout.validationFrames.map((frame: number, index: number) => ({ | |
key: frame, | |
frame, | |
name: gtJobMeta.frames[index]?.name | |
?? (gtJobMeta.frames[0]?.name ?? 'Unnamed Frame'), | |
active: !disabledFrames.includes(frame), | |
})); |
const updateMeta = async (): Promise<void> => { | ||
dispatch(reducerActions.setFetching(true)); | ||
try { | ||
const [newMeta] = await (state.gtJobInstance as Job).frames.save(); | ||
const validationLayout: TaskValidationLayout | null = await (instance as Task).validationLayout(); | ||
dispatch(reducerActions.setGtJobMeta(newMeta)); | ||
dispatch(reducerActions.setValidationLayout(validationLayout)); | ||
} finally { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add null checks to prevent potential null references in 'updateMeta' function
In the updateMeta
function, state.gtJobInstance
and instance
are used without verifying if they are not null
. If either is null
, this could lead to runtime errors when attempting to access their properties or methods.
Apply this diff to add null checks:
const updateMeta = async (): Promise<void> => {
dispatch(reducerActions.setFetching(true));
try {
+ if (state.gtJobInstance && instance) {
const [newMeta] = await state.gtJobInstance.frames.save();
const validationLayout: TaskValidationLayout | null = await instance.validationLayout();
dispatch(reducerActions.setGtJobMeta(newMeta));
dispatch(reducerActions.setValidationLayout(validationLayout));
+ } else {
+ notification.error({
+ message: 'Unable to update metadata',
+ description: 'Ground truth job instance or task instance is not available.',
+ });
+ }
} finally {
dispatch(reducerActions.setFetching(false));
}
};
📝 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.
const updateMeta = async (): Promise<void> => { | |
dispatch(reducerActions.setFetching(true)); | |
try { | |
const [newMeta] = await (state.gtJobInstance as Job).frames.save(); | |
const validationLayout: TaskValidationLayout | null = await (instance as Task).validationLayout(); | |
dispatch(reducerActions.setGtJobMeta(newMeta)); | |
dispatch(reducerActions.setValidationLayout(validationLayout)); | |
} finally { | |
const updateMeta = async (): Promise<void> => { | |
dispatch(reducerActions.setFetching(true)); | |
try { | |
if (state.gtJobInstance && instance) { | |
const [newMeta] = await state.gtJobInstance.frames.save(); | |
const validationLayout: TaskValidationLayout | null = await instance.validationLayout(); | |
dispatch(reducerActions.setGtJobMeta(newMeta)); | |
dispatch(reducerActions.setValidationLayout(validationLayout)); | |
} else { | |
notification.error({ | |
message: 'Unable to update metadata', | |
description: 'Ground truth job instance or task instance is not available.', | |
}); | |
} | |
} finally { | |
dispatch(reducerActions.setFetching(false)); | |
} | |
}; |
@@ -171,7 +174,7 @@ export function implementJob(Job: typeof JobClass): typeof JobClass { | |||
): ReturnType<typeof JobClass.prototype.validationLayout> { | |||
const result = await serverProxy.jobs.validationLayout(this.id); | |||
if (Object.keys(result).length) { | |||
return new ValidationLayout(result as Required<SerializedValidationLayout>); | |||
return new JobValidationLayout(result as SerializedJobValidationLayout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure 'result' is not null or undefined before accessing its properties
In the Job.prototype.validationLayout
implementation, there is a check for Object.keys(result).length
, but if result
is null
or undefined
, accessing Object.keys(result)
can cause a runtime error.
Consider adding a null check for result
before accessing its properties:
async function validationLayoutImplementation(
this: JobClass,
): ReturnType<typeof JobClass.prototype.validationLayout> {
const result = await serverProxy.jobs.validationLayout(this.id);
- if (Object.keys(result).length) {
+ if (result && Object.keys(result).length) {
return new JobValidationLayout(result as SerializedJobValidationLayout);
}
return null;
}
Committable suggestion was skipped due to low confidence.
const result = await serverProxy.tasks.validationLayout(this.id) as SerializedTaskValidationLayout; | ||
if (result.mode !== null) { | ||
return new TaskValidationLayout(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add null check for 'result' before accessing 'result.mode'
In the Task.prototype.validationLayout
implementation, there is an assumption that result
is not null or undefined. If serverProxy.tasks.validationLayout(this.id)
returns null
or undefined
, accessing result.mode
will result in a runtime error.
Recommend adding a null check for result
:
const result = await serverProxy.tasks.validationLayout(this.id) as SerializedTaskValidationLayout;
- if (result.mode !== null) {
+ if (result && result.mode !== null) {
return new TaskValidationLayout(result);
}
📝 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.
const result = await serverProxy.tasks.validationLayout(this.id) as SerializedTaskValidationLayout; | |
if (result.mode !== null) { | |
return new TaskValidationLayout(result); | |
const result = await serverProxy.tasks.validationLayout(this.id) as SerializedTaskValidationLayout; | |
if (result && result.mode !== null) { | |
return new TaskValidationLayout(result); |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8558 +/- ##
========================================
Coverage 74.26% 74.27%
========================================
Files 400 400
Lines 43218 43238 +20
Branches 3909 3914 +5
========================================
+ Hits 32096 32113 +17
- Misses 11122 11125 +3
|
Quality Gate passedIssues Measures |
Motivation and context
How has this been tested?
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation