Skip to content

Commit

Permalink
removed headless function
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov committed Nov 15, 2024
1 parent 38d47bd commit 874ba99
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 68 deletions.
26 changes: 19 additions & 7 deletions tests/cypress/e2e/features/ground_truth_jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/// <reference types="cypress" />

import { defaultGTJobSpec } from '../../support/default-specs';
import { defaultTaskSpec } from '../../support/default-specs';

context('Ground truth jobs', () => {
const labelName = 'car';
Expand All @@ -16,6 +16,12 @@ context('Ground truth jobs', () => {
fromTaskPage: true,
};

const defaultValidationParams = {
frameCount: 3,
mode: 'gt',
frameSelectionMethod: 'random_uniform',
};

const groundTruthRectangles = [
{
id: 1,
Expand Down Expand Up @@ -96,11 +102,17 @@ context('Ground truth jobs', () => {
cy.get('.cvat-quality-control-management-tab').should('exist').and('be.visible');
}

function createAndOpenTask(serverFiles, gtJobSpec = null) {
return cy.headlessCreateDummyTask({
taskName, serverFiles, labelName,
}, gtJobSpec ? defaultGTJobSpec(gtJobSpec) : null).then((response) => {
({ taskID, jobID, groundTruthJobID } = response);
function createAndOpenTask(serverFiles, validationParams = null) {
const { taskSpec, dataSpec, extras } = defaultTaskSpec({
taskName, serverFiles, labelName, validationParams,
});
return cy.headlessCreateTask(taskSpec, dataSpec, extras).then((taskResponse) => {
taskID = taskResponse.taskID;
if (validationParams) {
[groundTruthJobID, jobID] = taskResponse.jobIDs;
} else {
[jobID] = taskResponse.jobIDs;
}
}).then(() => {
cy.visit(`/tasks/${taskID}`);
cy.get('.cvat-task-details').should('exist').and('be.visible');
Expand Down Expand Up @@ -259,7 +271,7 @@ context('Ground truth jobs', () => {
const serverFiles = ['images/image_1.jpg', 'images/image_2.jpg', 'images/image_3.jpg'];

before(() => {
createAndOpenTask(serverFiles, { frameCount: 3 }).then(() => {
createAndOpenTask(serverFiles, defaultValidationParams).then(() => {
cy.visit(`/tasks/${taskID}/quality-control#management`);
cy.get('.cvat-quality-control-management-tab').should('exist').and('be.visible');
cy.get('.cvat-annotations-quality-allocation-table-summary').should('exist').and('be.visible');
Expand Down
34 changes: 0 additions & 34 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
/* eslint-disable security/detect-non-literal-regexp */

import { decomposeMatrix } from './utils';
import { defaultTaskSpec } from './default-specs';

require('cypress-file-upload');
require('../plugins/imageGenerator/imageGeneratorCommand');
Expand Down Expand Up @@ -383,39 +382,6 @@ Cypress.Commands.add('headlessCreateJob', (jobSpec) => {
});
});

Cypress.Commands.add('headlessCreateDummyTask', (taskParams, gtJobSpec = null) => {
const {
labelName, taskName, serverFiles, validationParams,
} = taskParams;
const { taskSpec, dataSpec, extras } = defaultTaskSpec({
taskName, serverFiles, labelName, validationParams,
});
let taskID = null;
let jobID = null;
let groundTruthJobID = null;
cy.headlessCreateTask(taskSpec, dataSpec, extras).then((taskResponse) => {
taskID = taskResponse.taskID;
if (validationParams) {
[groundTruthJobID, jobID] = taskResponse.jobIDs;
} else {
[jobID] = taskResponse.jobIDs;
}
}).then(() => {
if (gtJobSpec) {
return cy.headlessCreateJob({
task_id: taskID,
...gtJobSpec,
});
}
return null;
}).then((jobResponse) => {
if (jobResponse) {
groundTruthJobID = jobResponse.jobID;
}
return { taskID, jobID, groundTruthJobID };
});
});

Cypress.Commands.add('openTask', (taskName, projectSubsetFieldValue) => {
cy.contains('strong', new RegExp(`^${taskName}$`))
.parents('.cvat-tasks-list-item')
Expand Down
51 changes: 24 additions & 27 deletions tests/cypress/support/default-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,30 @@ function defaultTaskSpec({
sorting_method: (validationParams && validationParams.mode === 'gt_pool') ? 'random' : 'lexicographical',
};

const extras = validationParams ? {
validation_params: {
frames: validationParams.frames,
frame_selection_method: validationParams.frameSelectionMethod,
frame_count: validationParams.frameCount,
frames_per_job_count: validationParams.framesPerJobCount,
mode: validationParams.mode,
...(validationParams.randomSeed ? {
random_seed: validationParams.randomSeed,
} : {}),
},
} : {};
const extras = {};
if (validationParams) {
const convertedParams = {};
if (validationParams.frames) {
convertedParams.frames = validationParams.frames;
}
if (validationParams.frameSelectionMethod) {
convertedParams.frame_selection_method = validationParams.frameSelectionMethod;
}
if (validationParams.frameCount) {
convertedParams.frame_count = validationParams.frameCount;
}
if (validationParams.framesPerJobCount) {
convertedParams.frames_per_job_count = validationParams.framesPerJobCount;
}
if (validationParams.mode) {
convertedParams.mode = validationParams.mode;
}
if (validationParams.randomSeed) {
convertedParams.random_seed = validationParams.randomSeed;
}

extras.validation_params = convertedParams;
}

return {
taskSpec,
Expand All @@ -46,21 +58,6 @@ function defaultTaskSpec({
};
}

function defaultGTJobSpec({
frameCount = 3,
seed = null,
}) {
return {
frame_count: frameCount,
type: 'ground_truth',
frame_selection_method: 'random_uniform',
...(seed ? {
seed,
} : {}),
};
}

module.exports = {
defaultTaskSpec,
defaultGTJobSpec,
};

0 comments on commit 874ba99

Please sign in to comment.