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

Refactor _AnnotationMapper #9020

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

SpecLad
Copy link
Contributor

@SpecLad SpecLad commented Jan 30, 2025

Motivation and context

This has two main goals:

  1. Move all validation that does not depend on the task we're annotating from _AnnotationMapper and to DetectorFunctionSpec. This a) splits the code into more manageable chunks, and b) works better with the agent workflow, because the CLI function commands can reject an invalid function spec immediately (rather than waiting until the first request).

    (Frankly, I don't know why I didn't put this code in DetectorFunctionSpec in the first place, given that it implements the restrictions described in the docstring...)

    Validating the spec upon construction requires that the spec is not modified afterwards. This has always been my intention, but to make it clearer, state it explicitly in the docstring.

  2. Restructure the rest of the code into smaller functions. This should not introduce any differences in behavior.

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.

@SpecLad SpecLad force-pushed the refactor-annotation-mapper branch from 67e00a2 to 23e406e Compare January 30, 2025 10:37
This has two main goals:

1. Move all validation that does not depend on the task we're annotating
   from `_AnnotationMapper` and to `DetectorFunctionSpec`. This a) splits
   the code into more manageable chunks, and b) works better with the agent
   workflow, because the CLI `function` commands can reject an invalid
   function spec immediately (rather than waiting until the first request).

   (Frankly, I don't know why I didn't put this code in
   `DetectorFunctionSpec` in the first place, given that it implements the
   restrictions described in the docstring...)

   Validating the spec upon construction requires that the spec is not
   modified afterwards. This has always been my intention, but to make it
   clearer, state it explicitly in the docstring.

2. Restructure the rest of the code into smaller functions. This should not
   introduce any differences in behavior.
@SpecLad SpecLad force-pushed the refactor-annotation-mapper branch from 23e406e to 602ee28 Compare January 30, 2025 10:40
@SpecLad SpecLad marked this pull request as ready for review January 30, 2025 10:41
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 20.00000% with 92 lines in your changes missing coverage. Please review.

Project coverage is 73.39%. Comparing base (e7ce0c4) to head (602ee28).
Report is 6 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9020      +/-   ##
===========================================
- Coverage    73.39%   73.39%   -0.01%     
===========================================
  Files          416      417       +1     
  Lines        44198    44226      +28     
  Branches      3860     3860              
===========================================
+ Hits         32440    32458      +18     
- Misses       11758    11768      +10     
Components Coverage Δ
cvat-ui 77.36% <ø> (+<0.01%) ⬆️
cvat-server 70.08% <20.00%> (-0.02%) ⬇️

@SpecLad SpecLad merged commit 6402d20 into cvat-ai:develop Jan 30, 2025
42 checks passed
@SpecLad SpecLad deleted the refactor-annotation-mapper branch January 30, 2025 11:50
@cvat-bot cvat-bot bot mentioned this pull request Feb 4, 2025
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