Import cover images & external references#838
Import cover images & external references#838mihow merged 4 commits intodeployments/ood.antenna.insectai.orgfrom
Conversation
✅ Deploy Preview for antenna-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the taxa import and image reference functionality by adding new management commands and updating models, API views, serializers, and admin interfaces to support cover image URLs, clustering, and external references. Key changes include:
- Introducing the new management command “update_taxa” for bulk updating Taxon records.
- Updating models and migrations to add fields such as cover_image_url, cover_image_credit, unknown_species, and ood_score.
- Enhancing clustering and API endpoints to support new demo functionality and improving admin actions.
Reviewed Changes
Copilot reviewed 68 out of 68 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ami/ml/clustering_algorithms/agglomerative.py | Improved clustering functionality and minor logging string cleanup. |
| ami/main/management/commands/update_taxa.py | New management command with CSV processing improvements. |
| ami/jobs/models.py | Added DetectionClusteringJob with redundant status updates to review. |
| ... (other files) | Various migrations, API view, serializer, and admin interface updates. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new management command (update_taxa) for updating existing taxa data, enables new taxa filters and improves taxa import functionality. Key changes include the addition of a new filter in the UI, updating label text in species details, and modifications to the taxa import and update commands to support new fields such as cover image URLs and credits.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/src/utils/useFilters.ts | Added a new filter option with label "Show unobserved taxa". |
| ui/src/pages/species-details/species-details.tsx | Updated occurrence label from "Representative occurrence" to "Example occurrence". |
| ami/main/management/commands/update_taxa.py | Introduced a new management command for updating taxa using CSV input. |
| ami/main/management/commands/import_taxa.py | Enhanced taxon creation to include new fields and lookup by gbif_taxon_key. |
| ami/main/api/views.py | Extended API view to include cover image URL in the output. |
Comments suppressed due to low confidence (1)
ui/src/utils/useFilters.ts:115
- [nitpick] The filter name 'include_unobserved' may be inconsistent with the documented URL parameter 'include_observed'; please verify that the naming reflects the intended behavior.
label: 'Show unobserved taxa',
| reader = csv.DictReader(open(fname)) | ||
| taxa = [row for row in reader] |
There was a problem hiding this comment.
[nitpick] Consider using a context manager (e.g., 'with open(fname) as csvfile:') for reading the CSV to ensure the file is properly closed after use.
| reader = csv.DictReader(open(fname)) | |
| taxa = [row for row in reader] | |
| with open(fname) as csvfile: | |
| reader = csv.DictReader(csvfile) | |
| taxa = [row for row in reader] |
| # Assume ranks are in order of rank | ||
| if rank.name.lower() in taxon_data.keys() and taxon_data[rank.name.lower()]: | ||
| name = taxon_data[rank.name.lower()] | ||
| gbif_taxon_key = taxon_data.get("gbif_taxon_key", None) |
There was a problem hiding this comment.
Ensure that 'gbif_taxon_key' is validated (i.e., not None) before including it in the query filter, as passing None might lead to unintended matches in the lookup logic.
There was a problem hiding this comment.
@mihow remove the changes from import_taxa.py
* feat: management command for updating fields on existing Taxa from CSV * feat: try another title for example occurrence image * feat: allow manual filter for showing taxa without occurrences * feat: allow sorting by reference image for better demos
* Import cover images & external references (#838) * feat: management command for updating fields on existing Taxa from CSV * feat: try another title for example occurrence image * feat: allow manual filter for showing taxa without occurrences * feat: allow sorting by reference image for better demos * Fields for Taxon reference images (#822) * feat: add fields for Taxon cover images and Fieldguide ID * feat: add cover image fields to Taxon model for the UI * fix: look up existing taxa by name only * fix: update existing genus parents if their rank is wrong, don't crash * fix: don't allow empty CSV columns to clear existing data * fix: ensure all taxa in import list are added to taxa list in DB * fix: only keep changes related to importing taxa in this branch * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: missing migration after last commit in #946 this is only a configuration change, it does not alter the DB schema --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Import cover images & external references (#838) * feat: management command for updating fields on existing Taxa from CSV * feat: try another title for example occurrence image * feat: allow manual filter for showing taxa without occurrences * feat: allow sorting by reference image for better demos * Fields for Taxon reference images (#822) * feat: add fields for Taxon cover images and Fieldguide ID * feat: add cover image fields to Taxon model for the UI * fix: look up existing taxa by name only * fix: update existing genus parents if their rank is wrong, don't crash * fix: don't allow empty CSV columns to clear existing data * fix: ensure all taxa in import list are added to taxa list in DB

Summary
Adds management command to update any field on existing taxa
List of Changes
update_taxainclude_observedto show all species, regardless of occurrence countDeployment
Run this command in each environment to import images to known Panama species
Part of #813