-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -27,7 +27,10 @@ import { | |||||||||||||
decodePreview, | ||||||||||||||
} from './frames'; | ||||||||||||||
import Issue from './issue'; | ||||||||||||||
import { SerializedLabel, SerializedTask, SerializedValidationLayout } from './server-response-types'; | ||||||||||||||
import { | ||||||||||||||
SerializedLabel, SerializedTask, SerializedJobValidationLayout, | ||||||||||||||
SerializedTaskValidationLayout, | ||||||||||||||
} from './server-response-types'; | ||||||||||||||
import { checkInEnum, checkObjectType } from './common'; | ||||||||||||||
import { | ||||||||||||||
getCollection, getSaver, clearAnnotations, getAnnotations, | ||||||||||||||
|
@@ -37,7 +40,7 @@ import AnnotationGuide from './guide'; | |||||||||||||
import requestsManager from './requests-manager'; | ||||||||||||||
import { Request } from './request'; | ||||||||||||||
import User from './user'; | ||||||||||||||
import ValidationLayout from './validation-layout'; | ||||||||||||||
import { JobValidationLayout, TaskValidationLayout } from './validation-layout'; | ||||||||||||||
|
||||||||||||||
// must be called with task/job context | ||||||||||||||
async function deleteFrameWrapper(jobID, frame): Promise<void> { | ||||||||||||||
|
@@ -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 commentThe 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 Consider adding a null check for 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;
}
|
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
return null; | ||||||||||||||
|
@@ -641,9 +644,9 @@ export function implementTask(Task: typeof TaskClass): typeof TaskClass { | |||||||||||||
value: async function validationLayoutImplementation( | ||||||||||||||
this: TaskClass, | ||||||||||||||
): ReturnType<typeof TaskClass.prototype.validationLayout> { | ||||||||||||||
const result = await serverProxy.tasks.validationLayout(this.id); | ||||||||||||||
if (Object.keys(result).length) { | ||||||||||||||
return new ValidationLayout(result as Required<SerializedValidationLayout>); | ||||||||||||||
const result = await serverProxy.tasks.validationLayout(this.id) as SerializedTaskValidationLayout; | ||||||||||||||
if (result.mode !== null) { | ||||||||||||||
return new TaskValidationLayout(result); | ||||||||||||||
Comment on lines
+647
to
+649
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null check for 'result' before accessing 'result.mode' In the Recommend adding a null check for 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
Suggested change
|
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
return null; | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,37 +2,43 @@ | |||||||||||||||||
// | ||||||||||||||||||
// SPDX-License-Identifier: MIT | ||||||||||||||||||
|
||||||||||||||||||
import { SerializedValidationLayout } from 'server-response-types'; | ||||||||||||||||||
import { SerializedJobValidationLayout, SerializedTaskValidationLayout } from 'server-response-types'; | ||||||||||||||||||
import PluginRegistry from './plugins'; | ||||||||||||||||||
|
||||||||||||||||||
export default class ValidationLayout { | ||||||||||||||||||
#honeypotFrames: number[]; | ||||||||||||||||||
#honeypotRealFrames: number[]; | ||||||||||||||||||
export class JobValidationLayout { | ||||||||||||||||||
#honeypotCount: JobValidationLayout['honeypotCount']; | ||||||||||||||||||
#honeypotFrames: JobValidationLayout['honeypotFrames']; | ||||||||||||||||||
#honeypotRealFrames: JobValidationLayout['honeypotRealFrames']; | ||||||||||||||||||
Comment on lines
+8
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid circular type references in private field declarations Defining private fields with types that reference themselves can lead to circular type references, which might cause issues with type checking and readability. Consider defining the types explicitly: -export class JobValidationLayout {
- #honeypotCount: JobValidationLayout['honeypotCount'];
- #honeypotFrames: JobValidationLayout['honeypotFrames'];
- #honeypotRealFrames: JobValidationLayout['honeypotRealFrames'];
+export class JobValidationLayout {
+ #honeypotCount: number;
+ #honeypotFrames: number[];
+ #honeypotRealFrames: number[]; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
public constructor(data: Required<SerializedValidationLayout>) { | ||||||||||||||||||
this.#honeypotFrames = [...data.honeypot_frames]; | ||||||||||||||||||
this.#honeypotRealFrames = [...data.honeypot_real_frames]; | ||||||||||||||||||
public constructor(data: SerializedJobValidationLayout) { | ||||||||||||||||||
this.#honeypotCount = data.honeypot_count ?? 0; | ||||||||||||||||||
this.#honeypotFrames = [...(data.honeypot_frames ?? [])]; | ||||||||||||||||||
this.#honeypotRealFrames = [...(data.honeypot_real_frames ?? [])]; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public get honeypotFrames() { | ||||||||||||||||||
public get honeypotCount(): number { | ||||||||||||||||||
return this.#honeypotCount; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public get honeypotFrames(): number[] { | ||||||||||||||||||
return [...this.#honeypotFrames]; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public get honeypotRealFrames() { | ||||||||||||||||||
public get honeypotRealFrames(): number[] { | ||||||||||||||||||
return [...this.#honeypotRealFrames]; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
async getRealFrame(frame: number): Promise<number | null> { | ||||||||||||||||||
const result = await PluginRegistry.apiWrapper.call(this, ValidationLayout.prototype.getRealFrame, frame); | ||||||||||||||||||
const result = await PluginRegistry.apiWrapper.call(this, JobValidationLayout.prototype.getRealFrame, frame); | ||||||||||||||||||
return result; | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
Object.defineProperties(ValidationLayout.prototype.getRealFrame, { | ||||||||||||||||||
Object.defineProperties(JobValidationLayout.prototype.getRealFrame, { | ||||||||||||||||||
implementation: { | ||||||||||||||||||
writable: false, | ||||||||||||||||||
enumerable: false, | ||||||||||||||||||
value: function implementation(this: ValidationLayout, frame: number): number | null { | ||||||||||||||||||
value: function implementation(this: JobValidationLayout, frame: number): number | null { | ||||||||||||||||||
const index = this.honeypotFrames.indexOf(frame); | ||||||||||||||||||
if (index !== -1) { | ||||||||||||||||||
return this.honeypotRealFrames[index]; | ||||||||||||||||||
|
@@ -42,3 +48,28 @@ Object.defineProperties(ValidationLayout.prototype.getRealFrame, { | |||||||||||||||||
}, | ||||||||||||||||||
}, | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
export class TaskValidationLayout extends JobValidationLayout { | ||||||||||||||||||
#mode: TaskValidationLayout['mode']; | ||||||||||||||||||
#validationFrames: TaskValidationLayout['validationFrames']; | ||||||||||||||||||
#disabledFrames: TaskValidationLayout['disabledFrames']; | ||||||||||||||||||
Comment on lines
+52
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid circular type references in TaskValidationLayout's private fields Similar to 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
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
public constructor(data: SerializedTaskValidationLayout) { | ||||||||||||||||||
super(data); | ||||||||||||||||||
this.#mode = data.mode; | ||||||||||||||||||
this.#validationFrames = [...(data.validation_frames ?? [])]; | ||||||||||||||||||
this.#disabledFrames = [...(data.disabled_frames ?? [])]; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public get mode(): NonNullable<SerializedTaskValidationLayout['mode']> { | ||||||||||||||||||
return this.#mode; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public get validationFrames(): number[] { | ||||||||||||||||||
return [...this.#validationFrames]; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public get disabledFrames(): number[] { | ||||||||||||||||||
return [...this.#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.
💡 Codebase verification
ValidationLayout
Usages DetectedThe 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
andTaskValidationLayout
instead of the deprecatedValidationLayout
to maintain consistency and ensure type safety throughout the codebase.🔗 Analysis chain
LGTM: New validation layout types added to
classes
.The addition of
JobValidationLayout
andTaskValidationLayout
to theclasses
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:
Length of output: 777
Script:
Length of output: 5658
Script:
Length of output: 10973