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

Added a page with jobs #4258

Merged
merged 9 commits into from
Jan 31, 2022
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for working with ellipses (<https://github.com/openvinotoolkit/cvat/pull/4062>)
- Add several flags to task creation CLI (<https://github.com/openvinotoolkit/cvat/pull/4119>)
- Add YOLOv5 serverless function for automatic annotation (<https://github.com/openvinotoolkit/cvat/pull/4178>)
- Basic page with jobs list, basic filtration to this list (<https://github.com/openvinotoolkit/cvat/pull/4258>)

### Changed
- Users don't have access to a task object anymore if they are assigneed only on some jobs of the task (<https://github.com/openvinotoolkit/cvat/pull/3788>)
- Different resources (tasks, projects) are not visible anymore for all CVAT instance users by default (<https://github.com/openvinotoolkit/cvat/pull/3788>)
Expand Down
4 changes: 2 additions & 2 deletions cvat-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "4.1.2",
"version": "4.2.0",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "babel.config.js",
"scripts": {
Expand Down
25 changes: 15 additions & 10 deletions cvat-core/src/api-implementation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019-2021 Intel Corporation
// Copyright (C) 2019-2022 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -152,16 +152,16 @@ const config = require('./config');

cvat.jobs.get.implementation = async (filter) => {
checkFilter(filter, {
page: isInteger,
stage: isString,
state: isString,
assignee: isString,
taskID: isInteger,
jobID: isInteger,
});

if ('taskID' in filter && 'jobID' in filter) {
throw new ArgumentError('Only one of fields "taskID" and "jobID" allowed simultaneously');
}

if (!Object.keys(filter).length) {
throw new ArgumentError('Job filter must not be empty');
throw new ArgumentError('Filter fields "taskID" and "jobID" are not permitted to be used at the same time');
}

if ('taskID' in filter) {
Expand All @@ -173,12 +173,17 @@ const config = require('./config');
return [];
}

const job = await serverProxy.jobs.get(filter.jobID);
if (job) {
return [new Job(job)];
if ('jobID' in filter) {
const job = await serverProxy.jobs.get({ id: filter.jobID });
if (job) {
return [new Job(job)];
}
}

return [];
const jobsData = await serverProxy.jobs.get(filter);
const jobs = jobsData.results.map((jobData) => new Job(jobData));
jobs.count = jobsData.count;
return jobs;
};

cvat.tasks.get.implementation = async (filter) => {
Expand Down
4 changes: 2 additions & 2 deletions cvat-core/src/frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,11 @@
return frameDataCache[taskID].frameBuffer.getContextImage(frame);
}

async function getPreview(taskID) {
async function getPreview(taskID = null, jobID = null) {
return new Promise((resolve, reject) => {
// Just go to server and get preview (no any cache)
serverProxy.frames
.getPreview(taskID)
.getPreview(taskID, jobID)
.then((result) => {
if (isNode) {
// eslint-disable-next-line no-undef
Expand Down
28 changes: 20 additions & 8 deletions cvat-core/src/server-proxy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019-2021 Intel Corporation
// Copyright (C) 2019-2022 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -924,14 +924,25 @@
return createdTask[0];
}

async function getJob(jobID) {
async function getJobs(filter = {}) {
const { backendAPI } = config;
const id = filter.id || null;

let response = null;
try {
response = await Axios.get(`${backendAPI}/jobs/${jobID}`, {
proxy: config.proxy,
});
if (id !== null) {
response = await Axios.get(`${backendAPI}/jobs/${id}`, {
proxy: config.proxy,
});
} else {
response = await Axios.get(`${backendAPI}/jobs`, {
proxy: config.proxy,
params: {
...filter,
page_size: 12,
},
});
}
} catch (errorData) {
throw generateError(errorData);
}
Expand Down Expand Up @@ -1069,12 +1080,13 @@
return response.data;
}

async function getPreview(tid) {
async function getPreview(tid, jid) {
const { backendAPI } = config;

let response = null;
try {
response = await Axios.get(`${backendAPI}/tasks/${tid}/data`, {
const url = `${backendAPI}/${jid !== null ? 'jobs' : 'tasks'}/${jid || tid}/data`;
response = await Axios.get(url, {
params: {
type: 'preview',
},
Expand Down Expand Up @@ -1800,7 +1812,7 @@

jobs: {
value: Object.freeze({
get: getJob,
get: getJobs,
save: saveJob,
}),
writable: false,
Expand Down
10 changes: 9 additions & 1 deletion cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,11 @@
};

Job.prototype.frames.preview.implementation = async function () {
const frameData = await getPreview(this.taskId);
if (this.id === null || this.taskId === null) {
return '';
}

const frameData = await getPreview(this.taskId, this.jobID);
return frameData;
};

Expand Down Expand Up @@ -2220,6 +2224,10 @@
};

Task.prototype.frames.preview.implementation = async function () {
if (this.id === null) {
return '';
}

const frameData = await getPreview(this.id);
return frameData;
};
Expand Down
11 changes: 6 additions & 5 deletions cvat-core/tests/mocks/server-proxy.mock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020-2021 Intel Corporation
// Copyright (C) 2020-2022 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -212,7 +212,8 @@ class ServerProxy {
}
}

async function getJob(jobID) {
async function getJobs(filter = {}) {
const id = filter.id || null;
const jobs = tasksDummyData.results
.reduce((acc, task) => {
for (const segment of task.segments) {
Expand All @@ -234,7 +235,7 @@ class ServerProxy {

return acc;
}, [])
.filter((job) => job.id === jobID);
.filter((job) => job.id === id);

return (
jobs[0] || {
Expand Down Expand Up @@ -265,7 +266,7 @@ class ServerProxy {
}
}

return getJob(id);
return getJobs({ id });
}

async function getUsers() {
Expand Down Expand Up @@ -423,7 +424,7 @@ class ServerProxy {

jobs: {
value: Object.freeze({
get: getJob,
get: getJobs,
save: saveJob,
}),
writable: false,
Expand Down
4 changes: 2 additions & 2 deletions cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.33.3",
"version": "1.34.0",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
48 changes: 48 additions & 0 deletions cvat-ui/src/actions/jobs-actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (C) 2022 Intel Corporation
//
// SPDX-License-Identifier: MIT

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

const cvat = getCore();

export enum JobsActionTypes {
GET_JOBS = 'GET_JOBS',
GET_JOBS_SUCCESS = 'GET_JOBS_SUCCESS',
GET_JOBS_FAILED = 'GET_JOBS_FAILED',
}

interface JobsList extends Array<any> {
count: number;
}

const jobsActions = {
getJobs: (query: Partial<JobsQuery>) => createAction(JobsActionTypes.GET_JOBS, { query }),
getJobsSuccess: (jobs: JobsList, previews: string[]) => (
createAction(JobsActionTypes.GET_JOBS_SUCCESS, { jobs, previews })
),
getJobsFailed: (error: any) => createAction(JobsActionTypes.GET_JOBS_FAILED, { error }),
};

export type JobsActions = ActionUnion<typeof jobsActions>;

export const getJobsAsync = (query: JobsQuery): ThunkAction => async (dispatch) => {
try {
// Remove all keys with null values from the query
const filteredQuery: Partial<JobsQuery> = { ...query };
for (const [key, value] of Object.entries(filteredQuery)) {
if (value === null) {
delete filteredQuery[key];
}
}

dispatch(jobsActions.getJobs(filteredQuery));
const jobs = await cvat.jobs.get(filteredQuery);
const previewPromises = jobs.map((job: any) => (job as any).frames.preview().catch(() => ''));
dispatch(jobsActions.getJobsSuccess(jobs, await Promise.all(previewPromises)));
} catch (error) {
dispatch(jobsActions.getJobsFailed(error));
}
};
5 changes: 4 additions & 1 deletion cvat-ui/src/components/cvat-app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020-2021 Intel Corporation
// Copyright (C) 2020-2022 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -26,6 +26,8 @@ import ShortcutsDialog from 'components/shortcuts-dialog/shortcuts-dialog';
import ExportDatasetModal from 'components/export-dataset/export-dataset-modal';
import ModelsPageContainer from 'containers/models-page/models-page';

import JobsPageComponent from 'components/jobs-page/jobs-page';

import TasksPageContainer from 'containers/tasks-page/tasks-page';
import CreateTaskPageContainer from 'containers/create-task-page/create-task-page';
import TaskPageContainer from 'containers/task-page/task-page';
Expand Down Expand Up @@ -360,6 +362,7 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
<Route exact path='/tasks/create' component={CreateTaskPageContainer} />
<Route exact path='/tasks/:id' component={TaskPageContainer} />
<Route exact path='/tasks/:tid/jobs/:jid' component={AnnotationPageContainer} />
<Route exact path='/jobs' component={JobsPageComponent} />
<Route exact path='/cloudstorages' component={CloudStoragesPageComponent} />
<Route
exact
Expand Down
14 changes: 13 additions & 1 deletion cvat-ui/src/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ function HeaderContainer(props: Props): JSX.Element {
className='cvat-header-button'
type='link'
value='projects'
href='/projects'
href='/projects?page=1'
onClick={(event: React.MouseEvent): void => {
event.preventDefault();
history.push('/projects');
Expand All @@ -398,6 +398,18 @@ function HeaderContainer(props: Props): JSX.Element {
>
Tasks
</Button>
<Button
className='cvat-header-button'
type='link'
value='jobs'
href='/jobs?page=1'
onClick={(event: React.MouseEvent): void => {
event.preventDefault();
history.push('/jobs');
}}
>
Jobs
</Button>
<Button
className='cvat-header-button'
type='link'
Expand Down
2 changes: 0 additions & 2 deletions cvat-ui/src/components/header/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
align-items: center;

> a.ant-btn {
height: 24px;

span[role='img'] {
font-size: 24px;
line-height: 24px;
Expand Down
Loading