Skip to content

Commit

Permalink
Remove several fields from DataSerializer (#7663)
Browse files Browse the repository at this point in the history
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->
`original_chunk_type` and `compressed_chunk_type` have no effect,
because the task creation code overwrites these values based on
`use_zip_chunks`. With `size`, the code relies on the default of zero,
and attempting to overriding it will just lead to an incorrect value
being saved to the database.

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- ~~[ ] I have created a changelog fragment~~ <!-- see top comment in
CHANGELOG.md -->
- ~~[ ] I have updated the documentation accordingly~~
- ~~[ ] I have added tests to cover my changes~~
- ~~[ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))~~
- ~~[ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))~~

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
  • Loading branch information
SpecLad authored Apr 2, 2024
1 parent 02889ee commit 9c04b0c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
6 changes: 6 additions & 0 deletions changelog.d/20240322_193952_roman_clean_data_serializer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### Removed

- The `POST /api/tasks/{id}/data` endpoint no longer accepts several
parameters that didn't have any useful function: `size`,
`compressed_chunk_type`, `original_chunk_type`
(<https://github.com/opencv/cvat/pull/7663>)
2 changes: 1 addition & 1 deletion cvat/apps/engine/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def serialize_custom_file_mapping(db_segment: models.Segment):
def serialize_data():
data_serializer = DataSerializer(self._db_data)
data = data_serializer.data
data['chunk_type'] = data.pop('compressed_chunk_type')
data['chunk_type'] = self._db_data.compressed_chunk_type

# There are no deleted frames in DataSerializer so we need to pick it
data['deleted_frames'] = self._db_data.deleted_frames
Expand Down
4 changes: 1 addition & 3 deletions cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,7 @@ class DataSerializer(serializers.ModelSerializer):
class Meta:
model = models.Data
fields = (
'chunk_size', 'size', 'image_quality', 'start_frame', 'stop_frame', 'frame_filter',
'compressed_chunk_type', 'original_chunk_type',
'chunk_size', 'image_quality', 'start_frame', 'stop_frame', 'frame_filter',
'client_files', 'server_files', 'remote_files',
'use_zip_chunks', 'server_files_exclude',
'cloud_storage_id', 'use_cache', 'copy_data', 'storage_method',
Expand All @@ -952,7 +951,6 @@ class Meta:
)
extra_kwargs = {
'chunk_size': { 'help_text': "Maximum number of frames per chunk" },
'size': { 'help_text': "The number of frames" },
'start_frame': { 'help_text': "First frame index" },
'stop_frame': { 'help_text': "Last frame index" },
'frame_filter': { 'help_text': "Frame filter. The only supported syntax is: 'step=N'" },
Expand Down
9 changes: 0 additions & 9 deletions cvat/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6738,11 +6738,6 @@ components:
minimum: 0
nullable: true
description: Maximum number of frames per chunk
size:
type: integer
maximum: 2147483647
minimum: 0
description: The number of frames
image_quality:
type: integer
maximum: 100
Expand All @@ -6762,10 +6757,6 @@ components:
type: string
description: 'Frame filter. The only supported syntax is: ''step=N'''
maxLength: 256
compressed_chunk_type:
$ref: '#/components/schemas/ChunkType'
original_chunk_type:
$ref: '#/components/schemas/ChunkType'
client_files:
type: array
items:
Expand Down

0 comments on commit 9c04b0c

Please sign in to comment.