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

[GSoC2024] add return types to fix typescript warnings #7689

Merged
merged 14 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cvat-canvas/src/typescript/canvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
return this.controller.mode;
}

private onMessage = (messages: CanvasHint[] | null, topic: string) => {
private onMessage = (messages: CanvasHint[] | null, topic: string): void => {
this.canvas.dispatchEvent(
new CustomEvent('canvas.message', {
bubbles: false,
Expand Down
6 changes: 3 additions & 3 deletions cvat-canvas/src/typescript/objectSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ export class ObjectSelectorImpl implements ObjectSelector {
return filtered;
}

private onMouseDown = (event: MouseEvent) => {
private onMouseDown = (event: MouseEvent): void => {
const point = translateToSVG((this.canvas.node as any) as SVGSVGElement, [event.clientX, event.clientY]);
this.mouseDownPosition = { x: point[0], y: point[1] };
this.selectionRect = this.canvas.rect().addClass('cvat_canvas_selection_box');
this.selectionRect.attr({ 'stroke-width': consts.BASE_STROKE_WIDTH / this.geometry.scale });
this.selectionRect.attr({ ...this.mouseDownPosition });
};

private onMouseUp = (event: MouseEvent) => {
private onMouseUp = (event: MouseEvent): void => {
if (this.selectionRect) {
this.selectionRect.remove();
this.selectionRect = null;
Expand Down Expand Up @@ -138,7 +138,7 @@ export class ObjectSelectorImpl implements ObjectSelector {
}
};

private onMouseMove = (event: MouseEvent) => {
private onMouseMove = (event: MouseEvent): void => {
if (this.selectionRect) {
const box = this.getSelectionBox(event);
this.selectionRect.attr({
Expand Down
10 changes: 5 additions & 5 deletions cvat-core/src/annotations-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ export class SkeletonShape extends Shape {
return new ObjectState(this.get(frame));
}

const updateElements = (affectedElements, action, property: 'points' | 'occluded' | 'hidden' | 'lock') => {
const updateElements = (affectedElements, action, property: 'points' | 'occluded' | 'hidden' | 'lock'): void => {
const undoSkeletonProperties = this.elements.map((element) => element[property]);
const undoSource = this.source;
const redoSource = this.readOnlyFields.includes('source') ? this.source : computeNewSource(this.source);
Expand Down Expand Up @@ -2540,7 +2540,7 @@ class PolyTrack extends Track {
return updatedMatching;
}

function reduceInterpolation(interpolatedPoints, matching, leftPoints, rightPoints) {
function reduceInterpolation(interpolatedPoints, matching, leftPoints, rightPoints): void {
function averagePoint(points: Point2D[]): Point2D {
let sumX = 0;
let sumY = 0;
Expand All @@ -2559,7 +2559,7 @@ class PolyTrack extends Track {
return Math.sqrt((point1.x - point2.x) ** 2 + (point1.y - point2.y) ** 2);
}

function minimizeSegment(baseLength: number, N: number, startInterpolated, stopInterpolated) {
function minimizeSegment(baseLength: number, N: number, startInterpolated, stopInterpolated): void {
const threshold = baseLength / (2 * N);
const minimized = [interpolatedPoints[startInterpolated]];
let latestPushed = startInterpolated;
Expand Down Expand Up @@ -2596,7 +2596,7 @@ class PolyTrack extends Track {
interpolatedIndexes[i] = matching[i].map(() => accumulated++);
}

function leftSegment(start, stop) {
function leftSegment(start, stop): void {
const startInterpolated = interpolatedIndexes[start][0];
const stopInterpolated = interpolatedIndexes[stop][0];

Expand All @@ -2611,7 +2611,7 @@ class PolyTrack extends Track {
reduced.push(...minimizeSegment(baseLength, N, startInterpolated, stopInterpolated));
}

function rightSegment(leftPoint) {
function rightSegment(leftPoint): void {
const start = matching[leftPoint][0];
const [stop] = matching[leftPoint].slice(-1);
const startInterpolated = interpolatedIndexes[leftPoint][0];
Expand Down
30 changes: 26 additions & 4 deletions cvat-core/src/lambda-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,36 @@
import serverProxy from './server-proxy';
import { ArgumentError } from './exceptions';
import MLModel from './ml-model';
import { RQStatus } from './enums';
import { RQStatus, ShapeType } from './enums';

export interface ModelProvider {
name: string;
icon: string;
attributes: Record<string, string>;
}

export interface InteractorResults {
mask: number[][];
points?: [number, number][];
bounds?: [number, number, number, number]
}

export interface DetectedShape {
type: ShapeType;
rotation?: number;
attributes: { name: string; value: string }[];
label: string;
outside?: boolean;
points?: number[];
mask?: number[];
elements: DetectedShape[];
}

export interface TrackerResults {
states: any[];
shapes: number[][];
}

class LambdaManager {
private cachedList: MLModel[];
private listening: Record<number, {
Expand Down Expand Up @@ -43,7 +65,7 @@ class LambdaManager {
return { models, count: lambdaFunctions.length };
}

async run(taskID: number, model: MLModel, args: any) {
tahamukhtar20 marked this conversation as resolved.
Show resolved Hide resolved
async run(taskID: number, model: MLModel, args: any): Promise<string> {
if (!Number.isInteger(taskID) || taskID < 0) {
throw new ArgumentError(`Argument taskID must be a positive integer. Got "${taskID}"`);
}
Expand All @@ -68,7 +90,7 @@ class LambdaManager {
return result.id;
}

async call(taskID, model, args) {
async call(taskID, model, args): Promise<TrackerResults | InteractorResults | DetectedShape[]> {
if (!Number.isInteger(taskID) || taskID < 0) {
throw new ArgumentError(`Argument taskID must be a positive integer. Got "${taskID}"`);
}
Expand All @@ -81,7 +103,7 @@ class LambdaManager {
return result;
}

async requests() {
async requests(): Promise<any[]> {
const lambdaRequests = await serverProxy.lambda.requests();
return lambdaRequests
.filter((request) => [RQStatus.QUEUED, RQStatus.STARTED].includes(request.status));
Expand Down
Loading