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

Nuclio as a plugin in CVAT, improved system to check installed plugins #2192

Merged
merged 8 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 9 additions & 8 deletions components/analytics/docker-compose.analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ services:
context: ./components/analytics/kibana
args:
ELK_VERSION: 6.4.0
depends_on: ['cvat_elasticsearch']
depends_on: [ 'cvat_elasticsearch' ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to add extra spaces here?

restart: always

cvat_kibana_setup:
container_name: cvat_kibana_setup
image: cvat/server
volumes: ['./components/analytics/kibana:/home/django/kibana:ro']
depends_on: ['cvat']
volumes: [ './components/analytics/kibana:/home/django/kibana:ro' ]
depends_on: [ 'cvat' ]
working_dir: '/home/django'
entrypoint: ['bash', 'wait-for-it.sh', 'elasticsearch:9200', '-t', '0', '--',
'/bin/bash', 'wait-for-it.sh', 'kibana:5601', '-t', '0', '--',
'/usr/bin/python3', 'kibana/setup.py', 'kibana/export.json']
entrypoint: [ 'bash', 'wait-for-it.sh', 'elasticsearch:9200', '-t', '0', '--',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please keep indentation as is?

'/bin/bash', 'wait-for-it.sh', 'kibana:5601', '-t', '0', '--',
'/usr/bin/python3', 'kibana/setup.py', 'kibana/export.json' ]
environment:
no_proxy: elasticsearch,kibana,${no_proxy}

Expand All @@ -52,9 +52,9 @@ services:
context: ./components/analytics/logstash
args:
ELK_VERSION: 6.4.0
http_proxy: ${http_proxy}
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
depends_on: ['cvat_elasticsearch']
depends_on: [ 'cvat_elasticsearch' ]
restart: always

cvat:
Expand All @@ -63,6 +63,7 @@ services:
DJANGO_LOG_SERVER_PORT: 5000
DJANGO_LOG_VIEWER_HOST: kibana
DJANGO_LOG_VIEWER_PORT: 5601
CVAT_ANALYTICS: 1
no_proxy: kibana,logstash,nuclio,${no_proxy}

volumes:
Expand Down
7 changes: 7 additions & 0 deletions components/serverless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Serverless for Computer Vision Annotation Tool (CVAT)

### Run docker container
```bash
# From project root directory
docker-compose -f docker-compose.yml -f components/serverless/docker-compose.serverless.yml up -d
```
28 changes: 28 additions & 0 deletions components/serverless/docker-compose.serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '2.3'
services:
serverless:
container_name: nuclio
image: quay.io/nuclio/dashboard:1.4.8-amd64
restart: always
networks:
default:
aliases:
- nuclio
volumes:
- /tmp:/tmp
- /var/run/docker.sock:/var/run/docker.sock
environment:
http_proxy:
https_proxy:
no_proxy: 172.28.0.1,${no_proxy}
NUCLIO_CHECK_FUNCTION_CONTAINERS_HEALTHINESS: "true"
ports:
- "8070:8070"

cvat:
environment:
CVAT_SERVERLESS: 1
no_proxy: kibana,logstash,nuclio,${no_proxy}

volumes:
cvat_events:
5 changes: 5 additions & 0 deletions cvat-core/src/api-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@
return tasks;
};

cvat.allowedApps.list.implementation = async () => {
const result = await serverProxy.allowedApps.list();
return result;
};

return cvat;
}

Expand Down
48 changes: 28 additions & 20 deletions cvat-core/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function build() {
return result;
},
/**

* Method allows to register on a server
* @method register
* @async
Expand Down Expand Up @@ -470,34 +469,42 @@ function build() {
return result;
},
/**
* Install plugin to CVAT
* @method register
* @async
* @memberof module:API.cvat.plugins
* @param {Plugin} [plugin] plugin for registration
* @throws {module:API.cvat.exceptions.PluginError}
*/
* Install plugin to CVAT
* @method register
* @async
* @memberof module:API.cvat.plugins
* @param {Plugin} [plugin] plugin for registration
* @throws {module:API.cvat.exceptions.PluginError}
*/
async register(plugin) {
const result = await PluginRegistry
.apiWrapper(cvat.plugins.register, plugin);
return result;
},
},

allowedApps: {
async list() {
const result = await PluginRegistry.apiWrapper(cvat.allowedApps.list);
return result;
},
},
bsekachev marked this conversation as resolved.
Show resolved Hide resolved

/**
* Namespace is used for serverless functions management (mainly related with DL models)
* @namespace lambda
* @memberof module:API.cvat
*/
* Namespace is used for serverless functions management (mainly related with DL models)
* @namespace lambda
* @memberof module:API.cvat
*/
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}
*/
* 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);
Expand Down Expand Up @@ -746,6 +753,7 @@ function build() {
cvat.lambda = Object.freeze(cvat.lambda);
cvat.client = Object.freeze(cvat.client);
cvat.enums = Object.freeze(cvat.enums);
cvat.allowedApps = Object.freeze(cvat.allowedApps);

const implementAPI = require('./api-implementation');

Expand Down
18 changes: 17 additions & 1 deletion cvat-core/src/server-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@
}

async function cancelLambdaRequest(requestId) {
const { backendAPI } = config;
const {backendAPI} = config;
bsekachev marked this conversation as resolved.
Show resolved Hide resolved

try {
await Axios.delete(
Expand All @@ -812,6 +812,16 @@
}
}

async function getAllowedApps() {
const {backendAPI} = config;
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
try {
const response = await Axios.get(`${backendAPI}/apps/`);
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
return response.data;
} catch (errorData) {
throw generateError(errorData);
}
}

Object.defineProperties(this, Object.freeze({
server: {
value: Object.freeze({
Expand Down Expand Up @@ -896,6 +906,12 @@
}),
writable: false,
},
allowedApps: {
value: Object.freeze({
list: getAllowedApps,
}),
writable: false,
},
}));
}
}
Expand Down
44 changes: 44 additions & 0 deletions cvat-ui/src/actions/meta-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

import { ActionUnion, createAction, ThunkAction } from 'utils/redux';
import getCore from 'cvat-core-wrapper';
import { MetaState } from '../reducers/interfaces';


const core = getCore();

export enum MetaActionTypes {
GET_ALLOWED_APPS = 'GET_ALLOWED_APPS',
GET_ALLOWED_APPS_SUCCESS = 'GET_ALLOWED_APPS_SUCCESS',
GET_ALLOWED_APPS_FAILED = 'GET_ALLOWED_APPS_FAILED',
}

export const allowedAppsActions = {
getAllowedApps: () => createAction(MetaActionTypes.GET_ALLOWED_APPS),
getAllowedAppsSuccess: (data: MetaState) => createAction(MetaActionTypes.GET_ALLOWED_APPS_SUCCESS, {data}),
getAllowedAppsFailed: (error: any) => createAction(MetaActionTypes.GET_ALLOWED_APPS_FAILED, {error}),
};

export type AllowedAppsActions = ActionUnion<typeof allowedAppsActions>;

export const getAllowedAppsAsync = (): ThunkAction => async (dispatch): Promise<void> => {
dispatch(allowedAppsActions.getAllowedApps());

try {
const allowedApps: string[] = await core.allowedApps.list();

const data: MetaState = {
showTasksButton: allowedApps.includes('tasks'),
showAnalyticsButton: allowedApps.includes('analytics'),
showModelsButton: allowedApps.includes('serverless'),
};
console.log(data);
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
dispatch(
allowedAppsActions.getAllowedAppsSuccess(data),
);
} catch (error) {
dispatch(allowedAppsActions.getAllowedAppsFailed(error));
}
};
23 changes: 20 additions & 3 deletions cvat-ui/src/components/cvat-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ interface CVATAppProps {
authActionsInitialized: boolean;
notifications: NotificationsState;
user: any;
loadMeta: () => void;
metaInitialized: boolean;
metaFetching: boolean;
showModelsButton: boolean;
showAnalyticsButton: boolean;
}

class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentProps> {
Expand Down Expand Up @@ -115,6 +120,11 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
userAgreementsInitialized,
authActionsFetching,
authActionsInitialized,
loadMeta,
metaInitialized,
metaFetching,
showModelsButton,
showAnalyticsButton,
} = this.props;

this.showErrors();
Expand Down Expand Up @@ -150,13 +160,18 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
loadAbout();
}

if (!modelsInitialized && !modelsFetching) {
if (!metaInitialized && !metaFetching) {
loadMeta();
}

if (showModelsButton && !modelsInitialized && !modelsFetching) {
initModels();
}

if (!pluginsInitialized && !pluginsFetching) {
if (showAnalyticsButton && !pluginsInitialized && !pluginsFetching) {
initPlugins();
}
console.log(metaInitialized, showModelsButton, showAnalyticsButton);
}

private showMessages(): void {
Expand Down Expand Up @@ -246,13 +261,15 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
formatsInitialized,
switchShortcutsDialog,
switchSettingsDialog,
showAnalyticsButton,
user,
keyMap,
} = this.props;

const readyForRender = (userInitialized && (user == null || !user.isVerified))
|| (userInitialized && formatsInitialized
&& pluginsInitialized && usersInitialized && aboutInitialized);
&& (showAnalyticsButton === pluginsInitialized)
&& usersInitialized && aboutInitialized);

const subKeyMap = {
SWITCH_SHORTCUTS: keyMap.SWITCH_SHORTCUTS,
Expand Down
Loading