From 542365ef652095e2bf715c968795c7c5305e07a7 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Tue, 5 May 2020 15:42:36 +0300 Subject: [PATCH 1/2] session.annotations.put() returns indexes of added objects --- cvat-core/src/annotations-collection.js | 2 ++ cvat-core/src/session.js | 1 + cvat-core/tests/api/annotations.js | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cvat-core/src/annotations-collection.js b/cvat-core/src/annotations-collection.js index d3a7f4ac82a..1d9fc0fc9b1 100644 --- a/cvat-core/src/annotations-collection.js +++ b/cvat-core/src/annotations-collection.js @@ -806,6 +806,8 @@ object.removed = false; }); }, importedArray.map((object) => object.clientID), objectStates[0].frame); + + return importedArray.map((value) => value.clientID); } select(objectStates, x, y) { diff --git a/cvat-core/src/session.js b/cvat-core/src/session.js index 9643cb1bf17..dbbe7c38bf2 100644 --- a/cvat-core/src/session.js +++ b/cvat-core/src/session.js @@ -280,6 +280,7 @@ * @method put * @memberof Session.annotations * @param {module:API.cvat.classes.ObjectState[]} data + * @returns {number[]} indexes of added objects * array of objects on the specific frame * @throws {module:API.cvat.exceptions.PluginError} * @throws {module:API.cvat.exceptions.DataError} diff --git a/cvat-core/tests/api/annotations.js b/cvat-core/tests/api/annotations.js index e02f3c5a6fb..fca42dd3661 100644 --- a/cvat-core/tests/api/annotations.js +++ b/cvat-core/tests/api/annotations.js @@ -88,8 +88,10 @@ describe('Feature: put annotations', () => { zOrder: 0, }); - await task.annotations.put([state]); + const indexes = await task.annotations.put([state]); annotations = await task.annotations.get(1); + expect(indexes).toBeInstanceOf(Array); + expect(indexes).toHaveLength(1); expect(annotations).toHaveLength(length + 1); }); @@ -108,7 +110,9 @@ describe('Feature: put annotations', () => { zOrder: 0, }); - await job.annotations.put([state]); + const indexes = await job.annotations.put([state]); + expect(indexes).toBeInstanceOf(Array); + expect(indexes).toHaveLength(1); annotations = await job.annotations.get(5); expect(annotations).toHaveLength(length + 1); }); @@ -128,7 +132,9 @@ describe('Feature: put annotations', () => { zOrder: 0, }); - await task.annotations.put([state]); + const indexes = await task.annotations.put([state]); + expect(indexes).toBeInstanceOf(Array); + expect(indexes).toHaveLength(1); annotations = await task.annotations.get(1); expect(annotations).toHaveLength(length + 1); }); @@ -148,7 +154,9 @@ describe('Feature: put annotations', () => { zOrder: 0, }); - await job.annotations.put([state]); + const indexes = await job.annotations.put([state]); + expect(indexes).toBeInstanceOf(Array); + expect(indexes).toHaveLength(1); annotations = await job.annotations.get(5); expect(annotations).toHaveLength(length + 1); }); From 9ecc6cae1e846a19cd34bbedcc600130c9ad183e Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Tue, 5 May 2020 15:49:13 +0300 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 2 +- cvat-core/src/session.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb98ac4135f..77c4cb33045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ### Changed -- +- cvat-core: session.annotations.put() now returns identificators of added objects () ### Deprecated - diff --git a/cvat-core/src/session.js b/cvat-core/src/session.js index dbbe7c38bf2..1726766d328 100644 --- a/cvat-core/src/session.js +++ b/cvat-core/src/session.js @@ -280,7 +280,7 @@ * @method put * @memberof Session.annotations * @param {module:API.cvat.classes.ObjectState[]} data - * @returns {number[]} indexes of added objects + * @returns {number[]} identificators of added objects * array of objects on the specific frame * @throws {module:API.cvat.exceptions.PluginError} * @throws {module:API.cvat.exceptions.DataError}