From fe8134638b5b842e80e4e1f9c8bf316d68144eba Mon Sep 17 00:00:00 2001 From: "cvat-bot[bot]" <147643061+cvat-bot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 07:01:40 +0000 Subject: [PATCH 1/8] Update develop after v2.26.0 --- cvat-cli/requirements/base.txt | 2 +- cvat-cli/src/cvat_cli/version.py | 2 +- cvat-sdk/gen/generate.sh | 2 +- cvat-ui/package.json | 2 +- cvat/__init__.py | 2 +- cvat/schema.yml | 2 +- docker-compose.yml | 20 ++++++++++---------- helm-chart/values.yaml | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cvat-cli/requirements/base.txt b/cvat-cli/requirements/base.txt index 250770926d6a..bea402979e5b 100644 --- a/cvat-cli/requirements/base.txt +++ b/cvat-cli/requirements/base.txt @@ -1,4 +1,4 @@ -cvat-sdk==2.26.0 +cvat-sdk==2.26.1 attrs>=24.2.0 Pillow>=10.3.0 diff --git a/cvat-cli/src/cvat_cli/version.py b/cvat-cli/src/cvat_cli/version.py index 2933bf50fe86..d4640239b8ee 100644 --- a/cvat-cli/src/cvat_cli/version.py +++ b/cvat-cli/src/cvat_cli/version.py @@ -1 +1 @@ -VERSION = "2.26.0" +VERSION = "2.26.1" diff --git a/cvat-sdk/gen/generate.sh b/cvat-sdk/gen/generate.sh index 8bd1e827cd0c..52a32e9155a4 100755 --- a/cvat-sdk/gen/generate.sh +++ b/cvat-sdk/gen/generate.sh @@ -8,7 +8,7 @@ set -e GENERATOR_VERSION="v6.0.1" -VERSION="2.26.0" +VERSION="2.26.1" LIB_NAME="cvat_sdk" LAYER1_LIB_NAME="${LIB_NAME}/api_client" DST_DIR="$(cd "$(dirname -- "$0")/.." && pwd)" diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 5b6fb12aa699..fb7cf38d9611 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "2.26.0", + "version": "2.26.1", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat/__init__.py b/cvat/__init__.py index cbd559556988..81bf478b8753 100644 --- a/cvat/__init__.py +++ b/cvat/__init__.py @@ -4,6 +4,6 @@ from cvat.utils.version import get_version -VERSION = (2, 26, 0, "final", 0) +VERSION = (2, 26, 1, "alpha", 0) __version__ = get_version(VERSION) diff --git a/cvat/schema.yml b/cvat/schema.yml index 3524c606674d..dc42631d931f 100644 --- a/cvat/schema.yml +++ b/cvat/schema.yml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: CVAT REST API - version: 2.26.0 + version: 2.26.1 description: REST API for Computer Vision Annotation Tool (CVAT) termsOfService: https://www.google.com/policies/terms/ contact: diff --git a/docker-compose.yml b/docker-compose.yml index bda501c46def..1d83ad44754a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -81,7 +81,7 @@ services: cvat_server: container_name: cvat_server - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: <<: *backend-deps @@ -115,7 +115,7 @@ services: cvat_utils: container_name: cvat_utils - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: *backend-deps environment: @@ -132,7 +132,7 @@ services: cvat_worker_import: container_name: cvat_worker_import - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: *backend-deps environment: @@ -148,7 +148,7 @@ services: cvat_worker_export: container_name: cvat_worker_export - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: *backend-deps environment: @@ -164,7 +164,7 @@ services: cvat_worker_annotation: container_name: cvat_worker_annotation - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: *backend-deps environment: @@ -180,7 +180,7 @@ services: cvat_worker_webhooks: container_name: cvat_worker_webhooks - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: *backend-deps environment: @@ -196,7 +196,7 @@ services: cvat_worker_quality_reports: container_name: cvat_worker_quality_reports - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: *backend-deps environment: @@ -212,7 +212,7 @@ services: cvat_worker_analytics_reports: container_name: cvat_worker_analytics_reports - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: *backend-deps environment: @@ -228,7 +228,7 @@ services: cvat_worker_chunks: container_name: cvat_worker_chunks - image: cvat/server:${CVAT_VERSION:-v2.26.0} + image: cvat/server:${CVAT_VERSION:-dev} restart: always depends_on: *backend-deps environment: @@ -244,7 +244,7 @@ services: cvat_ui: container_name: cvat_ui - image: cvat/ui:${CVAT_VERSION:-v2.26.0} + image: cvat/ui:${CVAT_VERSION:-dev} restart: always depends_on: - cvat_server diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index cb6bef3f2515..59c517bda563 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -139,7 +139,7 @@ cvat: additionalVolumeMounts: [] replicas: 1 image: cvat/server - tag: v2.26.0 + tag: dev imagePullPolicy: Always permissionFix: enabled: true @@ -162,7 +162,7 @@ cvat: frontend: replicas: 1 image: cvat/ui - tag: v2.26.0 + tag: dev imagePullPolicy: Always labels: {} # test: test From 7e3f802908a069a8a8ca43689cd4357c3e3fc608 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 28 Jan 2025 13:58:22 +0200 Subject: [PATCH 2/8] Validate label types in the serializer (#8980) --- ...0122_142453_roman_labeltype_choicefield.md | 4 + .../migrations/0087_alter_label_type.py | 35 ++++++ cvat/apps/engine/models.py | 12 +-- cvat/apps/engine/serializers.py | 4 +- cvat/schema.yml | 102 +++++++++++++++--- cvat/settings/base.py | 1 + .../en/docs/manual/advanced/xml_format.md | 2 +- tests/python/rest_api/test_labels.py | 10 +- 8 files changed, 143 insertions(+), 27 deletions(-) create mode 100644 changelog.d/20250122_142453_roman_labeltype_choicefield.md create mode 100644 cvat/apps/engine/migrations/0087_alter_label_type.py diff --git a/changelog.d/20250122_142453_roman_labeltype_choicefield.md b/changelog.d/20250122_142453_roman_labeltype_choicefield.md new file mode 100644 index 000000000000..f9739ca4c8a6 --- /dev/null +++ b/changelog.d/20250122_142453_roman_labeltype_choicefield.md @@ -0,0 +1,4 @@ +### Fixed + +- The backend now rejects invalid label types + () diff --git a/cvat/apps/engine/migrations/0087_alter_label_type.py b/cvat/apps/engine/migrations/0087_alter_label_type.py new file mode 100644 index 000000000000..fc55e7bc2c23 --- /dev/null +++ b/cvat/apps/engine/migrations/0087_alter_label_type.py @@ -0,0 +1,35 @@ +# Generated by Django 4.2.17 on 2025-01-22 13:48 + +from django.db import migrations, models + +import cvat.apps.engine.models + + +class Migration(migrations.Migration): + + dependencies = [ + ("engine", "0086_profile_has_analytics_access"), + ] + + operations = [ + migrations.AlterField( + model_name="label", + name="type", + field=models.CharField( + choices=[ + ("any", "ANY"), + ("cuboid", "CUBOID"), + ("ellipse", "ELLIPSE"), + ("mask", "MASK"), + ("points", "POINTS"), + ("polygon", "POLYGON"), + ("polyline", "POLYLINE"), + ("rectangle", "RECTANGLE"), + ("skeleton", "SKELETON"), + ("tag", "TAG"), + ], + default=cvat.apps.engine.models.LabelType["ANY"], + max_length=32, + ), + ), + ] diff --git a/cvat/apps/engine/models.py b/cvat/apps/engine/models.py index 375e608d3b82..ff4213bc5da8 100644 --- a/cvat/apps/engine/models.py +++ b/cvat/apps/engine/models.py @@ -72,16 +72,16 @@ def __str__(self): return self.value class LabelType(str, Enum): - BBOX = 'bbox' + ANY = 'any' + CUBOID = 'cuboid' ELLIPSE = 'ellipse' + MASK = 'mask' + POINTS = 'points' POLYGON = 'polygon' POLYLINE = 'polyline' - POINTS = 'points' - CUBOID = 'cuboid' - CUBOID_3D = 'cuboid_3d' + RECTANGLE = 'rectangle' SKELETON = 'skeleton' TAG = 'tag' - ANY = 'any' @classmethod def choices(cls): @@ -946,7 +946,7 @@ class Label(models.Model): project = models.ForeignKey(Project, null=True, blank=True, on_delete=models.CASCADE) name = SafeCharField(max_length=64) color = models.CharField(default='', max_length=8) - type = models.CharField(max_length=32, null=True, choices=LabelType.choices(), default=LabelType.ANY) + type = models.CharField(max_length=32, choices=LabelType.choices(), default=LabelType.ANY) parent = models.ForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='sublabels') def __str__(self): diff --git a/cvat/apps/engine/serializers.py b/cvat/apps/engine/serializers.py index af8bfc759f2b..bf5dbdc7b363 100644 --- a/cvat/apps/engine/serializers.py +++ b/cvat/apps/engine/serializers.py @@ -288,7 +288,7 @@ class SublabelSerializer(serializers.ModelSerializer): color = serializers.CharField(allow_blank=True, required=False, help_text="The hex value for the RGB color. " "Will be generated automatically, unless specified explicitly.") - type = serializers.CharField(allow_blank=True, required=False, + type = serializers.ChoiceField(choices=models.LabelType.choices(), required=False, help_text="Associated annotation type for this label") has_parent = serializers.BooleanField(source='has_parent_label', required=False) @@ -418,7 +418,7 @@ def update_label( try: db_label = models.Label.create( name=validated_data.get('name'), - type=validated_data.get('type'), + type=validated_data.get('type', models.LabelType.ANY), parent=parent_label, **parent_info ) diff --git a/cvat/schema.yml b/cvat/schema.yml index dc42631d931f..4bbc544d86c8 100644 --- a/cvat/schema.yml +++ b/cvat/schema.yml @@ -2809,16 +2809,16 @@ paths: schema: type: string enum: - - bbox + - any + - cuboid - ellipse + - mask + - points - polygon - polyline - - points - - cuboid - - cuboid_3d + - rectangle - skeleton - tag - - any tags: - labels security: @@ -8487,8 +8487,21 @@ components: description: The list of attributes. If you want to remove an attribute, you need to recreate the label and specify the remaining attributes. type: - type: string - description: Associated annotation type for this label + allOf: + - $ref: '#/components/schemas/LabelType' + description: |- + Associated annotation type for this label + + * `any` - ANY + * `cuboid` - CUBOID + * `ellipse` - ELLIPSE + * `mask` - MASK + * `points` - POINTS + * `polygon` - POLYGON + * `polyline` - POLYLINE + * `rectangle` - RECTANGLE + * `skeleton` - SKELETON + * `tag` - TAG svg: type: string sublabels: @@ -8531,6 +8544,30 @@ components: a parent label required: - name + LabelType: + enum: + - any + - cuboid + - ellipse + - mask + - points + - polygon + - polyline + - rectangle + - skeleton + - tag + type: string + description: |- + * `any` - ANY + * `cuboid` - CUBOID + * `ellipse` - ELLIPSE + * `mask` - MASK + * `points` - POINTS + * `polygon` - POLYGON + * `polyline` - POLYLINE + * `rectangle` - RECTANGLE + * `skeleton` - SKELETON + * `tag` - TAG LabeledData: type: object properties: @@ -9589,8 +9626,21 @@ components: description: Delete the label. Only applicable in the PATCH methods of a project or a task. type: - type: string - description: Associated annotation type for this label + allOf: + - $ref: '#/components/schemas/LabelType' + description: |- + Associated annotation type for this label + + * `any` - ANY + * `cuboid` - CUBOID + * `ellipse` - ELLIPSE + * `mask` - MASK + * `points` - POINTS + * `polygon` - POLYGON + * `polyline` - POLYLINE + * `rectangle` - RECTANGLE + * `skeleton` - SKELETON + * `tag` - TAG svg: type: string sublabels: @@ -10764,8 +10814,21 @@ components: description: The list of attributes. If you want to remove an attribute, you need to recreate the label and specify the remaining attributes. type: - type: string - description: Associated annotation type for this label + allOf: + - $ref: '#/components/schemas/LabelType' + description: |- + Associated annotation type for this label + + * `any` - ANY + * `cuboid` - CUBOID + * `ellipse` - ELLIPSE + * `mask` - MASK + * `points` - POINTS + * `polygon` - POLYGON + * `polyline` - POLYLINE + * `rectangle` - RECTANGLE + * `skeleton` - SKELETON + * `tag` - TAG has_parent: type: boolean required: @@ -10804,8 +10867,21 @@ components: description: The list of attributes. If you want to remove an attribute, you need to recreate the label and specify the remaining attributes. type: - type: string - description: Associated annotation type for this label + allOf: + - $ref: '#/components/schemas/LabelType' + description: |- + Associated annotation type for this label + + * `any` - ANY + * `cuboid` - CUBOID + * `ellipse` - ELLIPSE + * `mask` - MASK + * `points` - POINTS + * `polygon` - POLYGON + * `polyline` - POLYLINE + * `rectangle` - RECTANGLE + * `skeleton` - SKELETON + * `tag` - TAG has_parent: type: boolean required: diff --git a/cvat/settings/base.py b/cvat/settings/base.py index ffb67869083a..3c933c18b901 100644 --- a/cvat/settings/base.py +++ b/cvat/settings/base.py @@ -662,6 +662,7 @@ class CVAT_QUEUES(Enum): 'COMPONENT_SPLIT_REQUEST': True, 'ENUM_NAME_OVERRIDES': { + 'LabelType': 'cvat.apps.engine.models.LabelType', 'ShapeType': 'cvat.apps.engine.models.ShapeType', 'OperationStatus': 'cvat.apps.engine.models.StateChoice', 'ChunkType': 'cvat.apps.engine.models.DataChoice', diff --git a/site/content/en/docs/manual/advanced/xml_format.md b/site/content/en/docs/manual/advanced/xml_format.md index 8d08d8c154dc..d6a08e88c16e 100644 --- a/site/content/en/docs/manual/advanced/xml_format.md +++ b/site/content/en/docs/manual/advanced/xml_format.md @@ -40,7 +40,7 @@ For what is `rle`, see [Run-length encoding](https://en.wikipedia.org/wiki/Run-l