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

Remove double updated_date bumping when saving annotations #7556

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

SpecLad
Copy link
Contributor

@SpecLad SpecLad commented Mar 5, 2024

Motivation and context

Currently, JobAnnotation.update needlessly bumps the updated_date of the job and the task twice (both via _delete and _create). These updates are costly in terms of time due to the various side effects associated with them (such as webhook sending and event logging), so it's better to avoid doing them gratuitously.

Change the code so that the bumps only happen once.

I simplified the code a bit; previously, the code in _delete would only bump the date if something was actually deleted (i.e., the annotations passed in actually existed in the database). Now we just check if there were any annotations we wanted to delete. This means that if a request only deletes non-existent annotations, the date will still get bumped. I don't think it's a significant issue, since this is a pathological case.

How has this been tested?

Manual testing

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.

Currently, `JobAnnotation.update` needlessly bumps the `updated_date` of the
job and the task twice (both via `_delete` and `_create`). These updates are
costly in terms of time due to the various side effects associated with them
(such as webhook sending and event logging), so it's better to avoid doing
them gratuitously.

Change the code so that the bumps only happen once.

I simplified the code a bit; previously, the code in `_delete` would only
bump the date if something was actually deleted (i.e., the annotations
passed in actually existed in the database). Now we just check if there were
any annotations we _wanted_ to delete. This means that if a request only
deletes non-existent annotations, the date will still get bumped. I don't
think it's a significant issue, since this is a pathological case.
@SpecLad SpecLad marked this pull request as ready for review March 5, 2024 17:49
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Merging #7556 (cd792fd) into develop (14b592f) will decrease coverage by 0.01%.
Report is 3 commits behind head on develop.
The diff coverage is 100.00%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7556      +/-   ##
===========================================
- Coverage    83.53%   83.52%   -0.01%     
===========================================
  Files          372      372              
  Lines        39661    39666       +5     
  Branches      3724     3724              
===========================================
+ Hits         33130    33131       +1     
- Misses        6531     6535       +4     
Components Coverage Δ
cvat-ui 79.40% <ø> (-0.03%) ⬇️
cvat-server 87.31% <100.00%> (+<0.01%) ⬆️

@SpecLad SpecLad removed the request for review from zhiltsov-max March 6, 2024 16:55
Copy link
Contributor

@nmanovic nmanovic left a comment

Choose a reason for hiding this comment

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

LGTM

But our API isn't optimal. It looks like UI should make separate requests if annotations are created, deleted and updated at the same time.

@nmanovic nmanovic merged commit b5014d1 into cvat-ai:develop Mar 8, 2024
43 checks passed
@cvat-bot cvat-bot bot mentioned this pull request Mar 11, 2024
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