From ac2790f95af8fa84e780aa3246f44329fc73f2f0 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Thu, 12 Aug 2021 12:16:23 +0300 Subject: [PATCH] Added dimension to project --- cvat-core/package-lock.json | 2 +- cvat-core/package.json | 2 +- cvat-core/src/project.js | 16 ++++++- .../export-dataset/export-dataset-modal.tsx | 47 ++++++++++--------- cvat/apps/engine/serializers.py | 11 +++-- 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/cvat-core/package-lock.json b/cvat-core/package-lock.json index e0b9594df794..15be69a6b42f 100644 --- a/cvat-core/package-lock.json +++ b/cvat-core/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-core", - "version": "3.14.0", + "version": "3.15.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-core/package.json b/cvat-core/package.json index 9c169475461a..229b9bec6ae8 100644 --- a/cvat-core/package.json +++ b/cvat-core/package.json @@ -1,6 +1,6 @@ { "name": "cvat-core", - "version": "3.14.0", + "version": "3.15.0", "description": "Part of Computer Vision Tool which presents an interface for client-side integration", "main": "babel.config.js", "scripts": { diff --git a/cvat-core/src/project.js b/cvat-core/src/project.js index bd25fc0f1b13..7e324498b95f 100644 --- a/cvat-core/src/project.js +++ b/cvat-core/src/project.js @@ -34,6 +34,7 @@ task_subsets: undefined, training_project: undefined, task_ids: undefined, + dimension: undefined, }; for (const property in data) { @@ -153,7 +154,7 @@ /** * @name createdDate * @type {string} - * @memberof module:API.cvat.classes.Task + * @memberof module:API.cvat.classes.Project * @readonly * @instance */ @@ -163,13 +164,24 @@ /** * @name updatedDate * @type {string} - * @memberof module:API.cvat.classes.Task + * @memberof module:API.cvat.classes.Project * @readonly * @instance */ updatedDate: { get: () => data.updated_date, }, + /** + * Dimesion of the tasks in the project, if no task dimension is null + * @name dimension + * @type {string} + * @memberof module:API.cvat.classes.Project + * @readonly + * @instance + */ + dimension: { + get: () => data.dimension, + }, /** * After project has been created value can be appended only. * @name labels diff --git a/cvat-ui/src/components/export-dataset/export-dataset-modal.tsx b/cvat-ui/src/components/export-dataset/export-dataset-modal.tsx index 400cdc4e21c7..d1660dfee782 100644 --- a/cvat-ui/src/components/export-dataset/export-dataset-modal.tsx +++ b/cvat-ui/src/components/export-dataset/export-dataset-modal.tsx @@ -34,9 +34,9 @@ function ExportDatasetModal(): JSX.Element { const instance = useSelector((state: CombinedState) => state.export.instance); const modalVisible = useSelector((state: CombinedState) => state.export.modalVisible); const dumpers = useSelector((state: CombinedState) => state.formats.annotationFormats.dumpers); - const { - tasks: taskExportActivities, projects: projectExportActivities, - } = useSelector((state: CombinedState) => state.export); + const { tasks: taskExportActivities, projects: projectExportActivities } = useSelector( + (state: CombinedState) => state.export, + ); const initActivities = (): void => { if (instance instanceof core.classes.Project) { @@ -62,19 +62,28 @@ function ExportDatasetModal(): JSX.Element { dispatch(exportActions.closeExportModal()); }; - const handleExport = useCallback((values: FormValues): void => { - // have to validate format before so it would not be undefined - dispatch( - exportDatasetAsync(instance, values.selectedFormat as string, values.customName ? `${values.customName}.zip` : '', values.saveImages), - ); - closeModal(); - Notification.info({ - message: 'Dataset export started', - description: `Dataset export was started for ${instanceType} #${instance?.id}. ` + - 'Download will start automaticly as soon as the dataset is ready.', - className: `cvat-notification-notice-export-${instanceType}-start`, - }); - }, [instance?.id, instance instanceof core.classes.Project, instanceType]); + const handleExport = useCallback( + (values: FormValues): void => { + // have to validate format before so it would not be undefined + dispatch( + exportDatasetAsync( + instance, + values.selectedFormat as string, + values.customName ? `${values.customName}.zip` : '', + values.saveImages, + ), + ); + closeModal(); + Notification.info({ + message: 'Dataset export started', + description: + `Dataset export was started for ${instanceType} #${instance?.id}. ` + + 'Download will start automaticly as soon as the dataset is ready.', + className: `cvat-notification-notice-export-${instanceType}-start`, + }); + }, + [instance?.id, instance instanceof core.classes.Project, instanceType], + ); return ( {dumpers .sort((a: any, b: any) => a.name.localeCompare(b.name)) - .filter( - (dumper: any): boolean => - !(instance instanceof core.classes.Task) || - dumper.dimension === instance?.dimension, - ) + .filter((dumper: any): boolean => dumper.dimension === instance?.dimension) .map( (dumper: any): JSX.Element => { const pending = (activities || []).includes(dumper.name); diff --git a/cvat/apps/engine/serializers.py b/cvat/apps/engine/serializers.py index 767b393e1f3b..f50e799bf427 100644 --- a/cvat/apps/engine/serializers.py +++ b/cvat/apps/engine/serializers.py @@ -504,13 +504,15 @@ class ProjectWithoutTaskSerializer(serializers.ModelSerializer): owner_id = serializers.IntegerField(write_only=True, allow_null=True, required=False) assignee = BasicUserSerializer(allow_null=True, required=False) assignee_id = serializers.IntegerField(write_only=True, allow_null=True, required=False) + task_subsets = serializers.ListField(child=serializers.CharField(), required=False) training_project = TrainingProjectSerializer(required=False, allow_null=True) + dimension = serializers.CharField(max_length=16, required=False) class Meta: model = models.Project fields = ('url', 'id', 'name', 'labels', 'tasks', 'owner', 'assignee', 'owner_id', 'assignee_id', - 'bug_tracker', 'created_date', 'updated_date', 'status', 'training_project') - read_only_fields = ('created_date', 'updated_date', 'status', 'owner', 'asignee') + 'bug_tracker', 'task_subsets', 'created_date', 'updated_date', 'status', 'training_project', 'dimension') + read_only_fields = ('created_date', 'updated_date', 'status', 'owner', 'asignee', 'task_subsets', 'dimension') ordering = ['-id'] @@ -519,6 +521,7 @@ def to_representation(self, instance): task_subsets = set(instance.tasks.values_list('subset', flat=True)) task_subsets.discard('') response['task_subsets'] = list(task_subsets) + response['dimension'] = instance.tasks.first().dimension if instance.tasks.count() else None return response class ProjectSerializer(ProjectWithoutTaskSerializer): @@ -580,7 +583,9 @@ def validate_labels(self, value): return value def to_representation(self, instance): - return serializers.ModelSerializer.to_representation(self, instance) # ignoring subsets here + response = serializers.ModelSerializer.to_representation(self, instance) # ignoring subsets here + response['dimension'] = instance.tasks.first().dimension if instance.tasks.count() else None + return response class ExceptionSerializer(serializers.Serializer): system = serializers.CharField(max_length=255)