-
Notifications
You must be signed in to change notification settings - Fork 5
Update Occurrence model to determine & save best examples #837
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
Update Occurrence model to determine & save best examples #837
Conversation
✅ Deploy Preview for antenna-preview canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the Occurrence model to include additional fields for tracking determination data and refactors the update_occurrence_determination function to improve clarity and maintainability. It also adds comprehensive tests to ensure that classifications and identifications update the occurrence determination as expected.
- Added new fields (favorite, best_detection, best_prediction, best_identification) to support determination tracking.
- Refactored the update_occurrence_determination function with a task_logger and field update batching.
- Added tests to validate behavior when using classifications and identifications.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
ami/main/tests/test_occurrence_determination.py | Added tests to validate occurrence determination logic. |
ami/main/tests/init.py | Added module docstring for test package. |
ami/main/models.py | Added new fields and refactored methods (including update_occurrence_determination). |
Comments suppressed due to low confidence (2)
ami/main/models.py:2466
- The get_best_identification method lacks an implementation; consider adding logic to retrieve and return the most recent human identification.
def get_best_identification(self) -> Identification | None:
ami/main/models.py:2611
- [nitpick] Resetting determination_score to None in this branch may be unintended; please verify that clearing this field when no identification or prediction exists aligns with the desired behavior.
if occurrence.determination_score is not None:
…nickLab/antenna into feat/occurrence-determination-fields
✅ Deploy Preview for antenna-ood canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors and extends the Occurrence model to track and determine the best examples by adding new fields and reworking methods for obtaining the best detection, prediction, and identification. Key changes include the addition of new foreign key fields (best_detection, best_prediction, best_identification) to Occurrence, refactoring of cached property methods into explicit getters for these values, and an update to the update_occurrence_determination method that now returns a tuple with updated fields.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
ami/main/tests/init.py | Added module docstring for tests. |
ami/main/models.py | Refactored methods to determine best detection, prediction, and identification; updated update_occurrence_determination and removed cached property cache invalidation. |
ami/main/migrations/0065_detection_favorite_occurrence_best_detection_and_more.py | Added new fields supporting best example selections. |
ami/main/migrations/0066_populate_cached_occurence_fields.py | Added migration to populate cached occurrence fields via a management command. |
ami/main/management/commands/update_occurrence_determinations.py | Added a new management command for updating occurrence determination fields. |
ami/main/api/serializers.py | Updated predictions field to use the get_best_predictions method as source. |
Summary
Add fields required for tracking which classifications are used for determinations. Currently it's not possible to know which algorithm or detection were used to determine the final species & score of an Occurrence. This adds fields to track that data. This will primarily be used to choose the most representative occurrence for a taxon, as well as the most representative detection for an occurrence.
Also as a consequence, this should speed up occurrence list requests greatly since is eliminates n+1 queries by saving the best classification & identification on the model instead of calculating them on the fly.
The
update_occurrence_determination
method was getting long and confusing, so this PR also refactors that method and adds a suite of tests.