Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSoC2024] - fixed attribute rename issue #7670

Merged
merged 15 commits into from
Apr 11, 2024

Conversation

ritikraj26
Copy link
Contributor

@ritikraj26 ritikraj26 commented Mar 24, 2024

Motivation and context

This PR fixes two open issues

Used attribute id to fetch attribute from the database and renamed it from the list received in the request.

How has this been tested?

Tested it under multiple scenarios, like different attribute types, input values, and labels.
image

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)
    - [ ] I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

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.

@nmanovic nmanovic requested review from nmanovic and removed request for bsekachev, Marishka17 and azhavoro March 25, 2024 11:09
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Merging #7670 (9c83fa9) into develop (33f9cc2) will increase coverage by 0.00%.
Report is 1 commits behind head on develop.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #7670   +/-   ##
========================================
  Coverage    83.44%   83.44%           
========================================
  Files          373      373           
  Lines        39724    39733    +9     
  Branches      3741     3741           
========================================
+ Hits         33147    33156    +9     
  Misses        6577     6577           
Components Coverage Δ
cvat-ui 79.24% <ø> (ø)
cvat-server 87.32% <100.00%> (+<0.01%) ⬆️

@nmanovic nmanovic requested review from Marishka17 and removed request for nmanovic March 28, 2024 14:50
Copy link
Contributor

@Marishka17 Marishka17 left a comment

Choose a reason for hiding this comment

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

Hello @ritikraj26, thank you for the contribution! We really appreciate your efforts. However, could you please consider implementing a slightly different approach?

Add a new id field to AttributeSerializer:

class AttributeSerializer(serializers.ModelSerializer):
    id = serializers.IntegerField(required=False)
    ...

In that case, you don't need to add explicitly id field into AttributeSpec model and create a new migration. Moreover, the attribute id will be available here (since each item of label.attributespec_set will include id) and you don't need to pass initial_data and "reinvent the wheel" on how to define attribute id.

Also, could you please add tests for checking that the renaming attributes functionality works as expected?

cvat/apps/engine/serializers.py Outdated Show resolved Hide resolved
cvat/apps/engine/serializers.py Outdated Show resolved Hide resolved
.python-version Outdated Show resolved Hide resolved
@ritikraj26
Copy link
Contributor Author

Hello @ritikraj26, thank you for the contribution! We really appreciate your efforts. However, could you please consider implementing a slightly different approach?

Add a new id field to AttributeSerializer:

class AttributeSerializer(serializers.ModelSerializer):
    id = serializers.IntegerField(required=False)
    ...

In that case, you don't need to add explicitly id field into AttributeSpec model and create a new migration. Moreover, the attribute id will be available here (since each item of label.attributespec_set will include id) and you don't need to pass initial_data and "reinvent the wheel" on how to define attribute id.

Also, could you please add tests for checking that the renaming attributes functionality works as expected?

Sure I will add the tests for checking this functionality.

@ritikraj26
Copy link
Contributor Author

Do I need to add the tests in test_labels.py or create a separate test_attributes.py?

@Marishka17
Copy link
Contributor

Do I need to add the tests in test_labels.py or create a separate test_attributes.py?

Yes, there is no need to create a separate test file, you can extend TestPatchLabels from test_labels.py

@ritikraj26
Copy link
Contributor Author

ritikraj26 commented Apr 5, 2024

I will have to modify the payload here to adjust the expected output.
However making changes in the update_lablel is not affecting the response here
The response here is generated from the actual endpoints?
@Marishka17

@ritikraj26
Copy link
Contributor Author

It seems to be working fine now. I had to clear the pytest cache.

@ritikraj26
Copy link
Contributor Author

@Marishka17 @nmanovic
Updated the PR and added tests.

Copy link
Contributor

@Marishka17 Marishka17 left a comment

Choose a reason for hiding this comment

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

Probably it will be better to consider submitting a separate PR with REST API tests, to speed up the merging of this PR.

Also, could you please create a changelog fragment? (scriv create --edit)

cvat/apps/engine/migrations/0079_alter_attributespec_id.py Outdated Show resolved Hide resolved
cvat/apps/engine/migrations/0080_alter_attributespec_id.py Outdated Show resolved Hide resolved
cvat/apps/engine/serializers.py Outdated Show resolved Hide resolved
cvat/apps/engine/serializers.py Outdated Show resolved Hide resolved
tests/python/rest_api/test_labels.py Outdated Show resolved Hide resolved
@ritikraj26
Copy link
Contributor Author

I removed the rest-api tests from this PR. I will add them in a separate PR.
@Marishka17 @nmanovic

@Marishka17
Copy link
Contributor

@ritikraj26, I see that tests are failing now. Could you please update the server schema? (Run the command docker run --rm --entrypoint /bin/bash cvat/server:dev -c 'python manage.py spectacular' > cvat/schema.yml or use VS Code command server: Generate REST API Schema)

@ritikraj26
Copy link
Contributor Author

@ritikraj26, I see that tests are failing now. Could you please update the server schema? (Run the command docker run --rm --entrypoint /bin/bash cvat/server:dev -c 'python manage.py spectacular' > cvat/schema.yml or use VS Code command server: Generate REST API Schema)

Done

@Marishka17
Copy link
Contributor

@ritikraj26, I see that tests are failing now. Could you please update the server schema? (Run the command docker run --rm --entrypoint /bin/bash cvat/server:dev -c 'python manage.py spectacular' > cvat/schema.yml or use VS Code command server: Generate REST API Schema)

Done

@ritikraj26, Looks like you forgot to commit changes (there are still no changes in the cvat/schema.yml file).

@ritikraj26
Copy link
Contributor Author

@ritikraj26, I see that tests are failing now. Could you please update the server schema? (Run the command docker run --rm --entrypoint /bin/bash cvat/server:dev -c 'python manage.py spectacular' > cvat/schema.yml or use VS Code command server: Generate REST API Schema)

Done

@ritikraj26, Looks like you forgot to commit changes (there are still no changes in the cvat/schema.yml file).

I pushed it. Could you check again?

Copy link
Contributor

@Marishka17 Marishka17 left a comment

Choose a reason for hiding this comment

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

LGTM

@Marishka17 Marishka17 merged commit 90d5e1f into cvat-ai:develop Apr 11, 2024
32 checks passed
@Marishka17
Copy link
Contributor

@ritikraj26, Thank you for the contribution!

@cvat-bot cvat-bot bot mentioned this pull request Apr 15, 2024
Marishka17 added a commit that referenced this pull request Jun 28, 2024
Added rest-api tests for attribute rename feature.

These rest-api tests are to validate the changes introduced in the PR
[here](#7670)

---------

Co-authored-by: Maria Khrustaleva <maria@cvat.ai>
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