Skip to content

Commit

Permalink
applied comments
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov committed Nov 14, 2024
1 parent a7aeb30 commit 057a5a0
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 66 deletions.
10 changes: 5 additions & 5 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint-disable security/detect-non-literal-regexp */

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

require('cypress-file-upload');
require('../plugins/imageGenerator/imageGeneratorCommand');
Expand Down Expand Up @@ -218,7 +218,7 @@ Cypress.Commands.add(
cy.advancedConfiguration(advancedConfigurationParams);
}
if (qualityConfigurationParams) {
cy.qualityConfiguration(qualityConfigurationParams);
cy.configureTaskQualityMode(qualityConfigurationParams);
}
cy.get('.cvat-submit-continue-task-button').scrollIntoView();
cy.get('.cvat-submit-continue-task-button').click();
Expand Down Expand Up @@ -314,7 +314,7 @@ Cypress.Commands.add('headlessCreateTask', (taskSpec, dataSpec, extras) => {
if (dataSpec.remote_files) {
task.remoteFiles = dataSpec.remote_files;
}
cy.log(extras);

const result = await task.save(extras || {});
return cy.wrap({ taskID: result.id, jobIDs: result.jobs.map((job) => job.id) });
});
Expand Down Expand Up @@ -387,7 +387,7 @@ Cypress.Commands.add('headlessCreateDummyTask', (taskParams, gtJobSpec = null) =
const {
labelName, taskName, serverFiles, validationParams,
} = taskParams;
const { taskSpec, dataSpec, extras } = dummyTaskSpec({
const { taskSpec, dataSpec, extras } = defaultTaskSpec({
taskName, serverFiles, labelName, validationParams,
});
let taskID = null;
Expand Down Expand Up @@ -935,7 +935,7 @@ Cypress.Commands.add('advancedConfiguration', (advancedConfigurationParams) => {
}
});

Cypress.Commands.add('qualityConfiguration', (qualityConfigurationParams) => {
Cypress.Commands.add('configureTaskQualityMode', (qualityConfigurationParams) => {
cy.contains('Quality').click();
if (qualityConfigurationParams.validationMode) {
cy.get('#validationMode').within(() => {
Expand Down
66 changes: 66 additions & 0 deletions tests/cypress/support/default-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright (C) 2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

function defaultTaskSpec({
labelName,
taskName,
serverFiles,
validationParams,
}) {
const taskSpec = {
labels: [
{ name: labelName, attributes: [], type: 'any' },
],
name: taskName,
project_id: null,
source_storage: { location: 'local' },
target_storage: { location: 'local' },
};

const dataSpec = {
server_files: serverFiles,
image_quality: 70,
use_zip_chunks: true,
use_cache: true,
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,
} : {}),
},
} : {};

return {
taskSpec,
dataSpec,
extras,
};
}

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

module.exports = {
defaultTaskSpec,
defaultGTJobSpec,
};
61 changes: 0 additions & 61 deletions tests/cypress/support/dummy-data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -90,68 +89,8 @@ const dummyAWSBucket = {
],
};

function dummyTaskSpec({
labelName,
taskName,
serverFiles,
validationParams,
}) {
const taskSpec = {
labels: [
{ name: labelName, attributes: [], type: 'any' },
],
name: taskName,
project_id: null,
source_storage: { location: 'local' },
target_storage: { location: 'local' },
};

const dataSpec = {
server_files: serverFiles,
image_quality: 70,
use_zip_chunks: true,
use_cache: true,
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,
} : {}),
},
} : {};

return {
taskSpec,
dataSpec,
extras,
};
}

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

module.exports = {
dummyGoogleStorage,
dummyAzureContainer,
dummyAWSBucket,
dummyTaskSpec,
dummyGTJobSpec,
};

0 comments on commit 057a5a0

Please sign in to comment.