Skip to content

Commit

Permalink
send uploadstart/uploadfinish requests in json format
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov committed Sep 20, 2024
1 parent 5bba804 commit b16c0fa
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
48 changes: 31 additions & 17 deletions cvat-core/src/server-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ async function healthCheck(
} catch (error) {
lastError = error;
if (attempt < adjustedMaxRetries) {
await new Promise((resolve) => setTimeout(resolve, adjustedCheckPeriod));
await new Promise((resolve) => { setTimeout(resolve, adjustedCheckPeriod); });
}
}
}
Expand All @@ -605,7 +605,7 @@ export interface ServerRequestConfig {
fetchAll: boolean,
}

export const sleep = (time: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, time));
export const sleep = (time: number): Promise<void> => new Promise((resolve) => { setTimeout(resolve, time); });

const defaultRequestConfig = {
fetchAll: false,
Expand Down Expand Up @@ -865,7 +865,8 @@ async function importDataset(
try {
if (isCloudStorage) {
const response = await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
});
return response.data.rq_id;
Expand All @@ -880,13 +881,15 @@ async function importDataset(
},
};
await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
headers: { 'Upload-Start': true },
});
await chunkUpload(file as File, uploadConfig);
const response = await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
headers: { 'Upload-Finish': true },
});
Expand Down Expand Up @@ -945,7 +948,8 @@ async function restoreTask(storage: Storage, file: File | string): Promise<strin
if (isCloudStorage) {
params.filename = file as string;
response = await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
});
return response.data.rq_id;
Expand All @@ -957,13 +961,15 @@ async function restoreTask(storage: Storage, file: File | string): Promise<strin
totalSize: (file as File).size,
};
await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
headers: { 'Upload-Start': true },
});
const { filename } = await chunkUpload(file as File, uploadConfig);
response = await Axios.post(url,
new FormData(), {
new FormData(),
{
params: { ...params, filename },
headers: { 'Upload-Finish': true },
});
Expand Down Expand Up @@ -1024,7 +1030,8 @@ async function restoreProject(storage: Storage, file: File | string): Promise<st
if (isCloudStorage) {
params.filename = file;
response = await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
});
return response.data.rq_id;
Expand All @@ -1036,13 +1043,15 @@ async function restoreProject(storage: Storage, file: File | string): Promise<st
totalSize: (file as File).size,
};
await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
headers: { 'Upload-Start': true },
});
const { filename } = await chunkUpload(file as File, uploadConfig);
response = await Axios.post(url,
new FormData(), {
new FormData(),
{
params: { ...params, filename },
headers: { 'Upload-Finish': true },
});
Expand Down Expand Up @@ -1088,7 +1097,7 @@ async function createTask(
value.forEach((element, idx) => {
taskData.append(`${key}[${idx}]`, element);
});
} else {
} else if (typeof value !== 'object') {
taskData.set(key, value);
}
}
Expand Down Expand Up @@ -1153,7 +1162,8 @@ async function createTask(
let rqID = null;
try {
await Axios.post(`${backendAPI}/tasks/${response.data.id}/data`,
taskData, {
{},
{
...params,
headers: { 'Upload-Start': true },
});
Expand All @@ -1178,7 +1188,8 @@ async function createTask(
await bulkUpload(response.data.id, bulkFiles);
}
const dataResponse = await Axios.post(`${backendAPI}/tasks/${response.data.id}/data`,
taskData, {
taskDataSpec,
{
...params,
headers: { 'Upload-Finish': true },
});
Expand Down Expand Up @@ -1568,7 +1579,8 @@ async function uploadAnnotations(
try {
if (isCloudStorage) {
const response = await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
});
return response.data.rq_id;
Expand All @@ -1579,13 +1591,15 @@ async function uploadAnnotations(
endpoint: `${origin}${backendAPI}/${session}s/${id}/annotations/`,
};
await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
headers: { 'Upload-Start': true },
});
await chunkUpload(file as File, uploadConfig);
const response = await Axios.post(url,
new FormData(), {
new FormData(),
{
params,
headers: { 'Upload-Finish': true },
});
Expand Down
2 changes: 0 additions & 2 deletions cvat-core/src/session-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,6 @@ export function implementTask(Task: typeof TaskClass): typeof TaskClass {
if (typeof this.id !== 'undefined') {
// If the task has been already created, we update it
const taskData = {
...fields,
...this._updateTrigger.getUpdated(this, {
bugTracker: 'bug_tracker',
projectId: 'project_id',
Expand Down Expand Up @@ -680,7 +679,6 @@ export function implementTask(Task: typeof TaskClass): typeof TaskClass {
}

const taskSpec: any = {
...fields,
name: this.name,
labels: this.labels.map((el) => el.toJSON()),
};
Expand Down
3 changes: 2 additions & 1 deletion cvat-ui/src/actions/tasks-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { filterNull } from 'utils/filter-null';
import { ThunkDispatch, ThunkAction } from 'utils/redux';

import { ValidationMode } from 'components/create-task-page/quality-configuration-form';
import { getInferenceStatusAsync } from './models-actions';
import { updateRequestProgress } from './requests-actions';

Expand Down Expand Up @@ -256,7 +257,7 @@ ThunkAction {

let extras = {};

if (data.quality.validationMode) {
if (data.quality.validationMode !== ValidationMode.NONE) {
extras = {
validation_params: {
mode: data.quality.validationMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Props {

export enum ValidationMode {
NONE = 'none',
GT = 'gt_job',
GT = 'gt',
HONEYPOTS = 'gt_pool',
}

Expand Down

0 comments on commit b16c0fa

Please sign in to comment.