Skip to content

Commit

Permalink
Refactor _AnnotationMapper (#9020)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SpecLad authored Jan 30, 2025
1 parent 3b5202e commit 6402d20
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 245 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Changed

- `DetectorFunctionSpec` will now raise `BadFunctionError` if it detects
any violations of the documented constraints on the labels
(<https://github.com/cvat-ai/cvat/pull/9020>)
3 changes: 2 additions & 1 deletion cvat-sdk/cvat_sdk/auto_annotation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: MIT

from .driver import BadFunctionError, annotate_task
from .driver import annotate_task
from .exceptions import BadFunctionError
from .interface import (
DetectionFunction,
DetectionFunctionContext,
Expand Down
Loading

0 comments on commit 6402d20

Please sign in to comment.