Skip to content

Commit

Permalink
made createTask return id and rq_id
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov committed May 23, 2024
1 parent 684d3ac commit a87fe59
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cvat-core/src/server-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ async function createTask(
taskSpec: Partial<SerializedTask>,
taskDataSpec: any,
onUpdate: (state: RQStatus, progress: number, message: string) => void,
): Promise<string> {
): Promise<{ taskID: number, rqID: string }> {
const { backendAPI, origin } = config;
// keep current default params to 'freeze" them during this request
const params = enableOrganization();
Expand Down Expand Up @@ -1229,7 +1229,7 @@ async function createTask(
}

const rqID = `create:task-${response.data.id}`;
return rqID;
return { taskID: response.data.id, rqID };
}

async function getJobs(
Expand Down
5 changes: 2 additions & 3 deletions cvat-core/src/session-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,14 @@ export function implementTask(Task) {
...(typeof this.cloudStorageId !== 'undefined' ? { cloud_storage_id: this.cloudStorageId } : {}),
};

const rqID = await serverProxy.tasks.create(
const { taskID, rqID } = await serverProxy.tasks.create(
taskSpec,
taskDataSpec,
options?.uploadStatusCallback || (() => {}),
);
const request = await requestsManager.listen(rqID, {
await requestsManager.listen(rqID, {
callback: options?.requestStatusCallback,
});
const taskID = request.operation?.taskID;
const [task] = await serverProxy.tasks.get({ id: taskID });
const labels = await serverProxy.labels.get({ task_id: task.id });
const jobs = await serverProxy.jobs.get({
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/tests/mocks/server-proxy.mock.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class ServerProxy {
labels: JSON.parse(JSON.stringify(taskData.labels)),
});

return id;
return { taskID: id, rqID: `create:task-${id}` };
}

async function deleteTask(id) {
Expand Down

0 comments on commit a87fe59

Please sign in to comment.