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

Requests page #7537

Closed
wants to merge 184 commits into from
Closed
Show file tree
Hide file tree
Changes from 178 commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
190c233
added mock server endpoints
klakhov Feb 9, 2024
0f0ced5
Merge branch 'develop' into kl/data-processing
klakhov Feb 12, 2024
b12bffe
prototype draft
klakhov Feb 14, 2024
67f369d
some adjustments to the server
klakhov Feb 14, 2024
7bedeab
show errors in cards
klakhov Feb 14, 2024
741c218
added header link
klakhov Feb 15, 2024
428b4cd
fixed collapse auto open
klakhov Feb 15, 2024
b91cb91
prototype preparations
klakhov Feb 15, 2024
fe0db3e
download only when ready
klakhov Feb 19, 2024
146072d
card structure change
klakhov Feb 19, 2024
3940e42
changes to demo v2
klakhov Feb 21, 2024
49484c6
Merge branch 'develop' into kl/data-processing
klakhov Feb 22, 2024
d6fb167
Merge branch 'develop' into kl/data-processing
klakhov Feb 26, 2024
9571d3c
updated server side, added pagination, empty component
klakhov Feb 27, 2024
7a3a2c2
Merge branch 'develop' into kl/data-processing
klakhov Feb 27, 2024
b2f356f
updated dates on cards
klakhov Feb 27, 2024
a5a5bf4
added error notification for fetching requests
klakhov Feb 27, 2024
397d5cb
Display full error message
klakhov Feb 27, 2024
3d46c03
fixed links
klakhov Feb 27, 2024
7862b93
moved format on the card
klakhov Feb 27, 2024
215754c
fixed notification
klakhov Feb 27, 2024
e468689
finalize project import/export
klakhov Feb 28, 2024
a0fe81b
fixed name
klakhov Feb 28, 2024
47ea9fb
import export for task/job
klakhov Feb 29, 2024
90bb023
backups
klakhov Feb 29, 2024
b49070f
refactored solution
klakhov Feb 29, 2024
fa6b99a
prettified code
klakhov Feb 29, 2024
477cc1d
Merge branch 'develop' into kl/data-processing
klakhov Mar 4, 2024
965ba21
added comment
klakhov Mar 4, 2024
d818fbc
improved notifications
klakhov Mar 4, 2024
16f493e
Merge branch 'develop' into kl/data-processing
klakhov Mar 6, 2024
811db70
Merge branch 'develop' into kl/data-processing
klakhov Mar 26, 2024
a109c78
Merge branch 'develop' into kl/data-processing
Marishka17 Apr 11, 2024
453aa4e
Refactor server code
Marishka17 Apr 16, 2024
d7f3aa5
Fix missing result url for exported backups
Marishka17 Apr 16, 2024
e0ab017
Handle redis exceptions
Marishka17 Apr 16, 2024
7640c7e
Clean up code && fix small bugs
Marishka17 Apr 17, 2024
9476bc6
[cvat-ui:request-card] Add delete/cancel actions && fix time format
Marishka17 Apr 17, 2024
7db407a
Merge branch 'develop' into kl/data-processing
klakhov Apr 22, 2024
09de287
fixed status message for queued
klakhov Apr 22, 2024
d9f794e
added pangination requests from ui
klakhov Apr 22, 2024
0be2a84
fixed sorting from new to old
klakhov Apr 22, 2024
f620181
fixed not reseting page on opening Requests tab
klakhov Apr 22, 2024
b7a66cd
Refactor code layout && fix small bugs && normalize used RQ IDs
Marishka17 Apr 22, 2024
f2b141d
Update server schema
Marishka17 Apr 22, 2024
455a8db
Merge branch 'develop' into kl/data-processing
Marishka17 Apr 22, 2024
b12f57d
Merge branch 'kl/data-processing' of https://github.com/cvat-ai/cvat …
klakhov Apr 22, 2024
ad5371e
Fix rq id parsing
Marishka17 Apr 22, 2024
e444fec
Remove user id from rq id for import job
Marishka17 Apr 22, 2024
e8463b7
Fix pylint issues
Marishka17 Apr 22, 2024
b5cbbd2
More robust handling of adding result_url to meta
Marishka17 Apr 22, 2024
6be9f03
Fix REST API tests
Marishka17 Apr 22, 2024
be628a6
Fix part of REST API tests
Marishka17 Apr 23, 2024
4ad0d78
Normailize viewset basename
Marishka17 Apr 23, 2024
d5f28f8
Update server schema
Marishka17 Apr 23, 2024
1e09d7a
Fix black issues
Marishka17 Apr 23, 2024
bfabf91
t
Marishka17 Apr 23, 2024
9a4baf1
isort
Marishka17 Apr 23, 2024
920f206
Fix missed decorator
Marishka17 Apr 23, 2024
9b88085
Fix typos
Marishka17 Apr 23, 2024
74aef09
Merge branch 'develop' into kl/data-processing
klakhov Apr 24, 2024
280bb3e
added duration for requests notificaitons
klakhov Apr 24, 2024
45d33fd
fixed notifications
klakhov Apr 25, 2024
00a5e72
listen to tasks
klakhov Apr 25, 2024
f6c3bc5
reworked cancel and delete
klakhov Apr 25, 2024
28a6d45
added more clear names for callbacks
klakhov Apr 25, 2024
de2ec86
fixed first test
klakhov Apr 25, 2024
51bb734
added exception for request errors
klakhov Apr 25, 2024
26c9bad
Merge branch 'kl/data-processing' of https://github.com/cvat-ai/cvat …
klakhov Apr 26, 2024
489557e
fixed a couple of bugs, fixed tests
klakhov Apr 26, 2024
750b9c6
updated cvat-core package
klakhov Apr 26, 2024
466ca55
updated cvat-ui package
klakhov Apr 26, 2024
b8ed90c
fixed possible undefined callbacks
klakhov Apr 26, 2024
a574252
fixed unit tests
klakhov Apr 26, 2024
3d4a7e1
fixed uncaught errors with tasks create
klakhov Apr 26, 2024
64c3d6c
Resolve conflicts
Marishka17 Apr 26, 2024
5adba32
removed using name on ui
klakhov Apr 28, 2024
dd12855
Revert missing code after merge
Marishka17 Apr 29, 2024
bc7e56f
Merge branch 'develop' into kl/data-processing
klakhov May 2, 2024
d428a1c
codestyle fixes
klakhov May 2, 2024
e49ce01
Add ability to sort and filter requests
Marishka17 May 4, 2024
9d435a6
Merge branch 'kl/data-processing' of https://github.com/opencv/cvat i…
Marishka17 May 4, 2024
efd64e0
Merge branch 'develop' into kl/data-processing
klakhov May 7, 2024
887ee65
updated styles
klakhov May 7, 2024
6f721bf
fixed notifications
klakhov May 7, 2024
bcd5b1d
fixed timestamps, updating requests
klakhov May 7, 2024
6069f40
Merge branch 'develop' into kl/data-processing
klakhov May 8, 2024
5393ac5
updated timeout system
klakhov May 8, 2024
e6e6af4
Merge branch 'develop' into kl/data-processing
klakhov May 13, 2024
09a691e
removed console log
klakhov May 13, 2024
0aaab07
fixed operations after refreshing the page
klakhov May 13, 2024
207a31d
fixed variable name
klakhov May 13, 2024
dd9909a
removed delete request
klakhov May 13, 2024
e2c11ab
updated types for import/export actions
klakhov May 13, 2024
2c6fb7a
[server] Fix several bugs && comments
Marishka17 May 14, 2024
272b517
fixed type guard
klakhov May 15, 2024
33d5756
adjusted request retry delays to prime number series
klakhov May 15, 2024
1fbbaab
improved timeout system
klakhov May 16, 2024
f28aee6
fixed multiple notifications
klakhov May 16, 2024
fa742d6
increased cypress requestTimeout
klakhov May 17, 2024
5f6de72
improved timeouts
klakhov May 17, 2024
a8919cb
added mouseout
klakhov May 17, 2024
6973236
fixed a couple of bugs
klakhov May 17, 2024
b508615
Merge branch 'develop' into kl/data-processing
klakhov May 17, 2024
68779c3
Merge branch 'develop' into kl/data-processing
klakhov May 20, 2024
ce3c547
[hotfix] changed request operation serializer name
klakhov May 20, 2024
4eeacf0
[hotfix] removed non-existent type
klakhov May 20, 2024
284e496
move request timeout to base config
klakhov May 20, 2024
a0384ff
[hotfix] fixed deffered jobs test
klakhov May 20, 2024
7ebe699
fixed error notifications with backups
klakhov May 22, 2024
66661ba
disabled request card after download
klakhov May 22, 2024
c854f25
moved callbacks from export
klakhov May 23, 2024
1a307d1
removed callback from import/backups
klakhov May 23, 2024
0209788
updated task creation
klakhov May 23, 2024
358e046
improved queued delays
klakhov May 23, 2024
8b02cec
improved listen to create for tasks
klakhov May 23, 2024
53cd931
applied comments to requests-manager
klakhov May 23, 2024
c0046b0
made Request read-only
klakhov May 23, 2024
90d269d
removed try-catches
klakhov May 23, 2024
af7c243
refactored rqIds
klakhov May 23, 2024
684d3ac
fixed backup/server proxy comments
klakhov May 23, 2024
a87fe59
made createTask return id and rq_id
klakhov May 23, 2024
bfba715
fixed consecutive export
klakhov May 23, 2024
b1bc728
removed excessive setters
klakhov May 23, 2024
c9d68dc
refactored to use common body
klakhov May 23, 2024
593b760
removed excessive check
klakhov May 23, 2024
ba0173c
Merged develop
bsekachev May 23, 2024
8720c48
Applied common style
bsekachev May 23, 2024
4ddc47a
Adjusted style
bsekachev May 23, 2024
f121324
fixed should log
klakhov May 24, 2024
d0be1c9
renamed action
klakhov May 24, 2024
2fa5039
applied small comments
klakhov May 24, 2024
de0cd19
removed excessive callback
klakhov May 24, 2024
5bf2910
refactored cvat-ui to use listening functions
klakhov May 25, 2024
b425878
added ability to export dataset and annotations simultaneously
klakhov May 27, 2024
f6a53ef
fixed export notification in case of not downloaded state
klakhov May 27, 2024
24cde45
Merge branch 'kl/data-processing' of https://github.com/cvat-ai/cvat …
klakhov May 27, 2024
3590701
small fixes
klakhov May 27, 2024
05f3366
refactored listening functions
klakhov May 27, 2024
2034551
updated menu
klakhov May 27, 2024
057c33e
reworked tests pipeline, intercept download before button press
klakhov May 27, 2024
ed4fdf6
applied a couple of comments
klakhov May 28, 2024
dc6cc10
updated test
klakhov May 28, 2024
1316776
small type fix
klakhov May 28, 2024
7062e92
removed imprt/export activities from state
klakhov May 28, 2024
822e9b5
removed other code with importing
klakhov May 28, 2024
9c02472
Merge branch 'develop' into kl/data-processing
klakhov May 28, 2024
5fbf35d
revert backup importing state
klakhov May 28, 2024
c175526
Merge branch 'kl/data-processing' of https://github.com/cvat-ai/cvat …
klakhov May 28, 2024
021c3ce
Merge branch 'develop' into kl/data-processing
klakhov May 28, 2024
00fcaa3
Merge branch 'develop' into kl/data-processing
bsekachev May 29, 2024
1cda2e3
Fixed linters
bsekachev May 29, 2024
b3bf1f9
Minor refactoring
bsekachev May 29, 2024
ad790c9
Renamed type
bsekachev May 29, 2024
e1ec671
Fix bugs && update sdk/REST API tests
Marishka17 May 30, 2024
705b1c4
applied comments
klakhov May 30, 2024
e202777
Merge branch 'develop' into kl/data-processing
klakhov May 31, 2024
6c4060e
applied more comments
klakhov May 31, 2024
270ecc0
Merge branch 'kl/data-processing' of https://github.com/cvat-ai/cvat …
klakhov May 31, 2024
9e66edb
count requests `count` dynamically
klakhov May 31, 2024
ade595d
Merge branch 'develop' into kl/data-processing
Marishka17 Jun 8, 2024
b136a3d
Add new API to export project/task/job dataset/backup
Marishka17 Jun 9, 2024
b64ef3b
Merge branch 'kl/data-processing' of https://github.com/opencv/cvat i…
Marishka17 Jun 9, 2024
43fde52
Merge branch 'develop' into kl/data-processing
klakhov Jun 18, 2024
9f1671b
small bugfixes
klakhov Jun 18, 2024
984b913
Fixed minor bugs & linters
klakhov Jun 19, 2024
4564860
fixed isort and e2e test
klakhov Jun 19, 2024
bcc0c90
Merge branch 'develop' into kl/data-processing
klakhov Jun 19, 2024
a4c9a37
fixed unit test
klakhov Jun 19, 2024
06e3b52
removed old comments
klakhov Jun 19, 2024
93c4ed0
fixed some sonarcloud issues
klakhov Jun 20, 2024
113af6d
Merge branch 'develop' into kl/data-processing
klakhov Jun 20, 2024
e19f4cf
ui fix: listening to create tasks on page refresh
klakhov Jun 20, 2024
a9aad8e
Merge branch 'develop' into kl/data-processing
klakhov Jun 24, 2024
75c3141
ui fix: jobs link, project update status callback
klakhov Jun 24, 2024
41414ea
[server] Clean up the code
Marishka17 Jun 26, 2024
802f41f
Merge branch 'kl/data-processing' of https://github.com/opencv/cvat i…
Marishka17 Jun 26, 2024
b5c7b4c
[server] Update schema
Marishka17 Jun 26, 2024
ad87af0
Fix pylint && cancel deferred backup job when there is no such job in…
Marishka17 Jun 26, 2024
aa9ec46
t
Marishka17 Jun 26, 2024
240bcd6
Merge branch 'develop' into kl/data-processing
Marishka17 Jun 26, 2024
15848cc
[server] Fix server schema: return rq id in response after initializi…
Marishka17 Jun 26, 2024
92a1964
Fix unit test
Marishka17 Jun 27, 2024
4ff3caa
Merge branch 'develop' into kl/data-processing
klakhov Jun 27, 2024
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
6 changes: 6 additions & 0 deletions changelog.d/20240515_100610_kirill.9992_data_processing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### Added

- Set of features to track background activities: importing/exporting datasets, annotations or backups, creating tasks.
Now you may find these processes on Requests page, it allows a user to understand current status of these activities
and enhances user experience, not losing progress when the browser tab is closed
(<https://github.com/cvat-ai/cvat/pull/7537>)
2 changes: 1 addition & 1 deletion cvat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "15.0.6",
"version": "15.1.0",
"type": "module",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "src/api.ts",
Expand Down
6 changes: 3 additions & 3 deletions cvat-core/src/annotations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2019-2022 Intel Corporation
// Copyright (C) 2022-2023 CVAT.ai Corporation
// Copyright (C) 2022-2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -168,9 +168,9 @@ export function importDataset(
file: File | string,
options: {
convMaskToPoly?: boolean,
updateStatusCallback?: (s: string, n: number) => void,
updateStatusCallback?: (message: string, progress: number) => void,
} = {},
): Promise<void> {
): Promise<string> {
const updateStatusCallback = options.updateStatusCallback || (() => {});
const convMaskToPoly = 'convMaskToPoly' in options ? options.convMaskToPoly : true;
const adjustedOptions = {
Expand Down
5 changes: 5 additions & 0 deletions cvat-core/src/api-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import config from './config';
import PluginRegistry from './plugins';
import serverProxy from './server-proxy';
import lambdaManager from './lambda-manager';
import requestsManager from './requests-manager';
import {
isBoolean,
isInteger,
Expand Down Expand Up @@ -61,6 +62,10 @@ export default function implementAPI(cvat: CVATCore): CVATCore {
implementationMixin(cvat.lambda.listen, lambdaManager.listen.bind(lambdaManager));
implementationMixin(cvat.lambda.requests, lambdaManager.requests.bind(lambdaManager));

implementationMixin(cvat.requests.list, requestsManager.list.bind(requestsManager));
implementationMixin(cvat.requests.listen, requestsManager.listen.bind(requestsManager));
implementationMixin(cvat.requests.cancel, requestsManager.cancel.bind(requestsManager));

implementationMixin(cvat.server.about, async () => {
const result = await serverProxy.server.about();
return result;
Expand Down
27 changes: 27 additions & 0 deletions cvat-core/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Organization from './organization';
import Webhook from './webhook';
import AnnotationGuide from './guide';
import BaseSingleFrameAction from './annotations-actions';
import { Request } from './request';

import * as enums from './enums';

Expand Down Expand Up @@ -286,6 +287,12 @@ function build(): CVATCore {
set globalObjectsCounter(value: number) {
config.globalObjectsCounter = value;
},
get requestsStatusDelay() {
return config.requestsStatusDelay;
},
set requestsStatusDelay(value) {
config.requestsStatusDelay = value;
},
},
client: {
version: `${pjson.version}`,
Expand Down Expand Up @@ -374,6 +381,26 @@ function build(): CVATCore {
},
},
},
requests: {
async list() {
const result = await PluginRegistry.apiWrapper(cvat.requests.list);
return result;
},
async cancel(rqID: string) {
const result = await PluginRegistry.apiWrapper(cvat.requests.cancel, rqID);
return result;
},
async listen(
rqID: string,
options: {
callback: (request: Request) => void,
initialRequest?: Request,
},
) {
const result = await PluginRegistry.apiWrapper(cvat.requests.listen, rqID, options);
return result;
},
},
classes: {
User,
Project: implementProject(Project),
Expand Down
2 changes: 2 additions & 0 deletions cvat-core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const config = {
},
onOrganizationChange: null,
globalObjectsCounter: 0,

requestsStatusDelay: null,
};

export default config;
4 changes: 3 additions & 1 deletion cvat-core/src/exceptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2019-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// Copyright (C) 2022-2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -99,6 +99,8 @@ export class DataError extends Exception {}

export class ScriptingError extends Exception {}

export class RequestError extends Exception {}

export class ServerError extends Exception {
public code: number;
constructor(message, code) {
Expand Down
13 changes: 13 additions & 0 deletions cvat-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import QualityConflict from './quality-conflict';
import QualitySettings from './quality-settings';
import AnalyticsReport from './analytics-report';
import AnnotationGuide from './guide';
import { Request } from './request';
import BaseSingleFrameAction, { listActions, registerAction, runActions } from './annotations-actions';
import {
ArgumentError, DataError, Exception, ScriptingError, ServerError,
Expand Down Expand Up @@ -150,6 +151,17 @@ export default interface CVATCore {
frames: {
getMeta: any;
};
requests: {
list: () => Promise<PaginatedResource<Request>>;
listen: (
rqID: string,
options: {
callback: (request: Request) => void,
initialRequest?: Request,
}
) => Promise<Request>;
cancel: (rqID: string) => Promise<void>;
};
actions: {
list: typeof listActions;
register: typeof registerAction;
Expand All @@ -166,6 +178,7 @@ export default interface CVATCore {
};
onOrganizationChange: (newOrgId: number | null) => void | null;
globalObjectsCounter: typeof config.globalObjectsCounter;
requestsStatusDelay: typeof config.requestsStatusDelay;
},
client: {
version: string;
Expand Down
20 changes: 11 additions & 9 deletions cvat-core/src/project-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,39 +107,42 @@ export default function implementProject(Project: typeof ProjectClass): typeof P
});

Object.defineProperty(Project.prototype.annotations.exportDataset, 'implementation', {
value: function exportDatasetImplementation(
value: async function exportDatasetImplementation(
this: ProjectClass,
format: Parameters<typeof ProjectClass.prototype.annotations.exportDataset>[0],
saveImages: Parameters<typeof ProjectClass.prototype.annotations.exportDataset>[1],
useDefaultSettings: Parameters<typeof ProjectClass.prototype.annotations.exportDataset>[2],
targetStorage: Parameters<typeof ProjectClass.prototype.annotations.exportDataset>[3],
customName: Parameters<typeof ProjectClass.prototype.annotations.exportDataset>[4],
): ReturnType<typeof ProjectClass.prototype.annotations.exportDataset> {
return exportDataset(this, format, saveImages, useDefaultSettings, targetStorage, customName);
const rqID = await exportDataset(this, format, saveImages, useDefaultSettings, targetStorage, customName);
return rqID;
},
});

Object.defineProperty(Project.prototype.annotations.importDataset, 'implementation', {
value: function importDatasetImplementation(
value: async function importDatasetImplementation(
this: ProjectClass,
format: Parameters<typeof ProjectClass.prototype.annotations.importDataset>[0],
useDefaultSettings: Parameters<typeof ProjectClass.prototype.annotations.importDataset>[1],
sourceStorage: Parameters<typeof ProjectClass.prototype.annotations.importDataset>[2],
file: Parameters<typeof ProjectClass.prototype.annotations.importDataset>[3],
options: Parameters<typeof ProjectClass.prototype.annotations.importDataset>[4],
): ReturnType<typeof ProjectClass.prototype.annotations.importDataset> {
return importDataset(this, format, useDefaultSettings, sourceStorage, file, options);
const rqID = await importDataset(this, format, useDefaultSettings, sourceStorage, file, options);
return rqID;
},
});

Object.defineProperty(Project.prototype.backup, 'implementation', {
value: function backupImplementation(
value: async function backupImplementation(
this: ProjectClass,
targetStorage: Parameters<typeof ProjectClass.prototype.backup>[0],
useDefaultSettings: Parameters<typeof ProjectClass.prototype.backup>[1],
fileName: Parameters<typeof ProjectClass.prototype.backup>[2],
): ReturnType<typeof ProjectClass.prototype.backup> {
return serverProxy.projects.backup(this.id, targetStorage, useDefaultSettings, fileName);
const rqID = await serverProxy.projects.backup(this.id, targetStorage, useDefaultSettings, fileName);
return rqID;
},
});

Expand All @@ -149,9 +152,8 @@ export default function implementProject(Project: typeof ProjectClass): typeof P
storage: Parameters<typeof ProjectClass.restore>[0],
file: Parameters<typeof ProjectClass.restore>[1],
): ReturnType<typeof ProjectClass.restore> {
const serializedProject = await serverProxy.projects.restore(storage, file);
const labels = await serverProxy.labels.get({ project_id: serializedProject.id });
return new Project({ ...serializedProject, labels: labels.results });
const rqID = await serverProxy.projects.restore(storage, file);
return rqID;
},
});

Expand Down
4 changes: 2 additions & 2 deletions cvat-core/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class Project {
convMaskToPoly?: boolean,
updateStatusCallback?: (s: string, n: number) => void,
},
) => Promise<void>;
) => Promise<string>;
};

constructor(initialData: Readonly<SerializedProject & { labels?: SerializedLabel[] }>) {
Expand Down Expand Up @@ -246,7 +246,7 @@ export default class Project {
return result;
}

static async restore(storage: Storage, file: File | string): Promise<Project> {
static async restore(storage: Storage, file: File | string): Promise<string> {
const result = await PluginRegistry.apiWrapper.call(this, Project.restore, storage, file);
return result;
}
Expand Down
105 changes: 105 additions & 0 deletions cvat-core/src/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright (C) 2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import { RQStatus } from './enums';
import User from './user';
import { SerializedRequest } from './server-response-types';

type Operation = {
target: string;
type: string;
format: string;
jobID: number | null;
taskID: number | null;
projectID: number | null;
};

export class Request {
#id: string;
#status: RQStatus;
#operation: Partial<SerializedRequest['operation']>;
#message: string;
#progress: number;
#resultUrl: string;
#resultID: number;
#enqueuedDate: string;
#startedDate: string;
#finishedDate: string;
#expiryDate: string;
#owner: User;

constructor(initialData: SerializedRequest) {
this.#id = initialData.id;
this.#status = initialData.status as RQStatus;
this.#operation = initialData.operation;
this.#progress = initialData.progress;
this.#message = initialData.message;
this.#resultUrl = initialData.result_url;
this.#resultID = initialData.result_id;

this.#enqueuedDate = initialData.enqueued_date;
this.#startedDate = initialData.started_date;
this.#finishedDate = initialData.finished_date;
this.#expiryDate = initialData.expiry_date;

if (initialData.owner) {
this.#owner = new User(initialData.owner);
}
}

get id(): string {
return this.#id;
}

get status(): RQStatus {
return this.#status.toLowerCase() as RQStatus;
klakhov marked this conversation as resolved.
Show resolved Hide resolved
}

get progress(): number {
return this.#progress;
}

get message(): string {
return this.#message;
}

get operation(): Operation {
return {
target: this.#operation.target,
type: this.#operation.type,
format: this.#operation.format,
jobID: this.#operation.job_id,
taskID: this.#operation.task_id,
projectID: this.#operation.project_id,
};
}

get url(): string {
return this.#resultUrl;
}

get resultID(): number {
return this.#resultID;
}

get enqueuedDate(): string {
return this.#enqueuedDate;
}

get startedDate(): string {
return this.#startedDate;
}

get finishedDate(): string {
return this.#finishedDate;
}

get expiryDate(): string {
return this.#expiryDate;
}

get owner(): User {
return this.#owner;
}
}
Loading
Loading