Skip to content

Split annotation types into more specific ones#10543

Open
zhiltsov-max wants to merge 6 commits intodevelopfrom
zm/refactor-annotation-types
Open

Split annotation types into more specific ones#10543
zhiltsov-max wants to merge 6 commits intodevelopfrom
zm/refactor-annotation-types

Conversation

@zhiltsov-max
Copy link
Copy Markdown
Contributor

@zhiltsov-max zhiltsov-max commented Apr 28, 2026

Motivation and context

Split annotation types into more detailed subclasses for easier combination.

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

@zhiltsov-max zhiltsov-max requested a review from SpecLad as a code owner April 28, 2026 08:59
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread cvat/apps/engine/models.py Outdated

class Meta:
abstract = True
default_permissions = ()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually needed? I thought it was just a holdover from Django's permission system (which we don't use).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it. but I think it should be removed everywhere, if we're not using it.

related_name='attributes', related_query_name='attribute')

class TrackedShape(Shape):
class TrackedShape(FrameAnnotationMixin, ShapeAnnotationMixin):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little weird to have this include annotation mixins when it is not itself an annotation... Maybe "Annotation" should be removed from the base class names or replaced with something else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These mixins are supposed for annotation classes, and it's reflected in the class names. This class is an annotation, even though it's not inherited from Annotation. I think there could be another annotation base class, but it would only contain id or be empty, so it doesn't look like a good addition so far.

Comment thread cvat/apps/engine/serializers.py Outdated
class ScoredAnnotationSerializer(serializers.Serializer):
score = serializers.FloatField(min_value=0, max_value=1, default=1)

class ImageAnnotationSerializer(serializers.Serializer):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class ImageAnnotationSerializer(serializers.Serializer):
class FrameAnnotationSerializer(serializers.Serializer):

This would be consistent with the model mixin.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

data['value'] = str(data['value'])
return super().to_internal_value(data)

class AttributedAnnotationSerializer(serializers.Serializer):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a nitpick, but IMO these mini-serializers should be moved after AnnotationSerializer for consistency with models.py.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a little bit overkill. The files are modified independently, I don't think it makes sense to maintain the order of type definitions without strong reasons for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants