Skip to content

Commit

Permalink
Squached changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev committed Jul 15, 2020
1 parent e95660c commit 140d3a5
Show file tree
Hide file tree
Showing 12 changed files with 495 additions and 302 deletions.
4 changes: 2 additions & 2 deletions cvat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "3.1.0",
"version": "3.2.0",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "babel.config.js",
"scripts": {
Expand All @@ -27,7 +27,7 @@
"eslint-plugin-security": "^1.4.0",
"jest": "^24.8.0",
"jest-junit": "^6.4.0",
"jsdoc": "^3.6.2",
"jsdoc": "^3.6.4",
"webpack": "^4.31.0",
"webpack-cli": "^3.3.2"
},
Expand Down
14 changes: 9 additions & 5 deletions cvat-core/src/api-implementation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Intel Corporation
* Copyright (C) 2019-2020 Intel Corporation
* SPDX-License-Identifier: MIT
*/

Expand All @@ -12,6 +12,7 @@
(() => {
const PluginRegistry = require('./plugins');
const serverProxy = require('./server-proxy');
const lambdaManager = require('./lambda-manager');
const {
isBoolean,
isInteger,
Expand All @@ -20,10 +21,7 @@
checkFilter,
} = require('./common');

const {
TaskStatus,
TaskMode,
} = require('./enums');
const { TaskStatus, TaskMode } = require('./enums');

const User = require('./user');
const { AnnotationFormats } = require('./annotation-formats.js');
Expand Down Expand Up @@ -54,6 +52,12 @@
cvat.plugins.list.implementation = PluginRegistry.list;
cvat.plugins.register.implementation = PluginRegistry.register.bind(cvat);

cvat.lambda.list.implementation = lambdaManager.list.bind(lambdaManager);
cvat.lambda.run.implementation = lambdaManager.run.bind(lambdaManager);
cvat.lambda.cancel.implementation = lambdaManager.cancel.bind(lambdaManager);
cvat.lambda.listen.implementation = lambdaManager.listen.bind(lambdaManager);
cvat.lambda.requests.implementation = lambdaManager.requests.bind(lambdaManager);

cvat.server.about.implementation = async () => {
const result = await serverProxy.server.about();
return result;
Expand Down
125 changes: 120 additions & 5 deletions cvat-core/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function build() {
const Statistics = require('./statistics');
const { Job, Task } = require('./session');
const { Attribute, Label } = require('./labels');
const MLModel = require('./ml-model');

const {
ShareFileType,
Expand All @@ -30,6 +31,7 @@ function build() {
ObjectShape,
LogType,
HistoryActions,
RQStatus,
colors,
} = require('./enums');

Expand Down Expand Up @@ -127,10 +129,10 @@ function build() {
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ServerError}
*/
async userAgreements() {
const result = await PluginRegistry
.apiWrapper(cvat.server.userAgreements);
return result;
async userAgreements() {
const result = await PluginRegistry
.apiWrapper(cvat.server.userAgreements);
return result;
},
/**
Expand All @@ -148,7 +150,15 @@ function build() {
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ServerError}
*/
async register(username, firstName, lastName, email, password1, password2, userConfirmations) {
async register(
username,
firstName,
lastName,
email,
password1,
password2,
userConfirmations,
) {
const result = await PluginRegistry
.apiWrapper(cvat.server.register, username, firstName,
lastName, email, password1, password2, userConfirmations);
Expand Down Expand Up @@ -423,6 +433,108 @@ function build() {
return result;
},
},
/**
* Namespace is used for serverless functions management (mainly related with DL models)
* @namespace lambda
* @memberof module:API.cvat
*/
/**
* @typedef {Object} RunLambdaArguments
* @property {boolean} [cleanup] flag that means shall
* we remove previous annotation or not
* @property {Object} [mapping] label mapping [model label -> task label]
* @property {number} [frame] annotate only a specific frame
* @global
*/
lambda: {
/**
* Method returns list of available serverless models
* @method list
* @async
* @memberof module:API.cvat.lambda
* @returns {module:API.cvat.classes.MLModel[]}
* @throws {module:API.cvat.exceptions.ServerError}
* @throws {module:API.cvat.exceptions.PluginError}
*/
async list() {
const result = await PluginRegistry
.apiWrapper(cvat.lambda.list);
return result;
},

/**
* Run serverless function on a specific task
* @method run
* @async
* @memberof module:API.cvat.lambda
* @param {module:API.cvat.classes.Task} task task to be annotated
* @param {module:API.cvat.classes.MLModel} model model used to get annotation
* @param {RunLambdaArguments} [arguments] extra arguments
* @returns {string} requestID
* @throws {module:API.cvat.exceptions.ServerError}
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ArgumentError}
*/
async run(task, model, args) {
const result = await PluginRegistry
.apiWrapper(cvat.lambda.run, task, model, args);
return result;
},

/**
* Cancel running of a serverless function for a specific task
* @method cancel
* @async
* @memberof module:API.cvat.lambda
* @param {string} requestID
* @throws {module:API.cvat.exceptions.ServerError}
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ArgumentError}
*/
async cancel(requestID) {
const result = await PluginRegistry
.apiWrapper(cvat.lambda.cancel, requestID);
return result;
},

/**
* @callback onRequestStatusChange
* @param {string} status
* @param {number} progress
* @param {string} [message]
* @global
*/
/**
* Listen for a specific request
* @method listen
* @async
* @memberof module:API.cvat.lambda
* @param {string} requestID
* @param {onRequestStatusChange} onChange
* @throws {module:API.cvat.exceptions.ArgumentError}
* @throws {module:API.cvat.exceptions.ServerError}
* @throws {module:API.cvat.exceptions.PluginError}
*/
async listen(requestID, onChange) {
const result = await PluginRegistry
.apiWrapper(cvat.lambda.listen, requestID, onChange);
return result;
},

/**
* Get active lambda requests
* @method requests
* @async
* @memberof module:API.cvat.lambda
* @throws {module:API.cvat.exceptions.ServerError}
* @throws {module:API.cvat.exceptions.PluginError}
*/
async requests() {
const result = await PluginRegistry
.apiWrapper(cvat.lambda.requests);
return result;
},
},
/**
* Namespace to working with logs
* @namespace logger
Expand Down Expand Up @@ -530,6 +642,7 @@ function build() {
ObjectShape,
LogType,
HistoryActions,
RQStatus,
colors,
},
/**
Expand Down Expand Up @@ -559,6 +672,7 @@ function build() {
Label,
Statistics,
ObjectState,
MLModel,
},
};

Expand All @@ -567,6 +681,7 @@ function build() {
cvat.jobs = Object.freeze(cvat.jobs);
cvat.users = Object.freeze(cvat.users);
cvat.plugins = Object.freeze(cvat.plugins);
cvat.lambda = Object.freeze(cvat.lambda);
cvat.client = Object.freeze(cvat.client);
cvat.enums = Object.freeze(cvat.enums);

Expand Down
34 changes: 34 additions & 0 deletions cvat-core/src/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
COMPLETED: 'completed',
});

/**
* List of RQ statuses
* @enum {string}
* @name RQStatus
* @memberof module:API.cvat.enums
* @property {string} QUEUED 'queued'
* @property {string} STARTED 'started'
* @property {string} FINISHED 'finished'
* @property {string} FAILED 'failed'
* @property {string} UNKNOWN 'unknown'
* @readonly
*/
const RQStatus = Object.freeze({
QUEUED: 'queued',
STARTED: 'started',
FINISHED: 'finished',
FAILED: 'failed',
UNKNOWN: 'unknown',
});

/**
* Task modes
* @enum {string}
Expand Down Expand Up @@ -216,6 +236,18 @@
REMOVED_OBJECT: 'Removed object',
});

/**
* Enum string values.
* @name ModelType
* @memberof module:API.cvat.enums
* @enum {string}
*/
const ModelType = {
DETECTOR: 'detector',
INTERACTOR: 'interactor',
TRACKER: 'tracker',
};

/**
* Array of hex colors
* @name colors
Expand All @@ -239,7 +271,9 @@
ObjectType,
ObjectShape,
LogType,
ModelType,
HistoryActions,
RQStatus,
colors,
};
})();
Loading

0 comments on commit 140d3a5

Please sign in to comment.