Skip to content

CLI reference

manage.py commands for Trapper Expert. Run inside the container:

docker compose exec trapper bash
python /app/trapper-project/manage.py <command> [args]

…or via trapper-setup:

./admin.py manage trapper <command> -p <profile> -- [args]

For trapper-setup's own CLI (configure.py, admin.py) see Deploy with trapper-setup. For trapper-tools, see its own docs (linked from Convert, package & upload with Trapper-Tools).

Taxonomy

import_gbif_taxonomy : Import species from the bundled GBIF Backbone CSVs. Idempotent.

python manage.py import_gbif_taxonomy --taxa mammalia aves --mode create
python manage.py import_gbif_taxonomy --taxa mammalia --mode update --dry-run
--taxa (required) — one or more of mammalia aves reptilia amphibia, space-separated (it's an nargs="+" list, not a comma-separated string — passing mammalia,aves as one token fails). --modecreate (insert only, default) or update (match-then-upsert). --dry-run — preview, don't write.

add_gbif_override : Append manual taxonomy overrides by querying the GBIF API.

python manage.py add_gbif_override mammalia "Bison bonasus,Lynx lynx"
taxon (positional) — restricted to taxa that actually have an override CSV (currently only mammalia — see OVERRIDE_FILES in gbif_utils.py; aves/reptilia/amphibia have none yet and are rejected). names (positional, comma-separated) — scientific names to look up. Writes to trapper/apps/extra_tables/taxonomy/gbif_<taxon>_overrides.csv.

AI / model sync

sync_ai_models : Pull the AI Manager's prediction-model catalog + bundled trapper-schemas category YAMLs, create/update AIProvider rows, resolve gbifSpeciesKeySpecies.taxon_id for every species AttributeLabel. Idempotent.

python manage.py sync_ai_models
Run on a fresh deployment (the admin wizard does it once), after upgrading the pinned trapper-schemas rev, or after the AI Manager re-registers a model (the SHA-256 model-file-hash is the join key).

!!! note
    `sync_ai_models` does **not** download model weights — that's the AI Worker coordinator's job, driven by `model_manifest.yaml`.

Classifications

rebuild_classification_msgpacks : Regenerate Classification.frames_msgpack files from source data — images from the dyn_attrs JSON columns, videos from the project's ObjectFrameObservation hypertable (only with --include-videos; the hypertable must already be populated for that project).

python manage.py rebuild_classification_msgpacks --project 42
python manage.py rebuild_classification_msgpacks --project 42 --force --include-videos
python manage.py rebuild_classification_msgpacks --classification 12345
python manage.py rebuild_classification_msgpacks --all-projects --dry-run
--project N / --classification N / --all-projects (mutually exclusive, required). --force — rebuild even if a msgpack file already exists (default: skip). --include-videos. --dry-run.

Hypertable

configure_hypertable : Inspect/tune the TimescaleDB hypertable backing ObjectFrameObservation. Safe to re-run.

python manage.py configure_hypertable --show
python manage.py configure_hypertable --chunk-interval "30 days"
python manage.py configure_hypertable --compress-after "60 days"
python manage.py configure_hypertable --compress-segmentby "project_id,classification_id"
python manage.py configure_hypertable --chunk-interval "30 days" --compress-after "14 days" --dry-run
See Frame hypertable.

populate_project_hypertable : Populate a project's ObjectFrameObservation snapshot from its classifications' existing msgpack files, downsampled to a target fps. Tracked per-project via ProjectHypertablePopulation.status.

python manage.py populate_project_hypertable --project 42
python manage.py populate_project_hypertable --project 42 --fps 5 --sync
python manage.py populate_project_hypertable --all-projects --fps 1
--project N / --all-projects (mutually exclusive, required). --fps N (default 1). --sync — run inline instead of dispatching to Celery. See Frame hypertable.

Data lifecycle

generate_thumbnails : Generate/regenerate thumbnail and preview images for resources. Multi-threaded; safe to run on a live system.

python manage.py generate_thumbnails --all
python manage.py generate_thumbnails --missing both --threads 8
python manage.py generate_thumbnails --filter "project_id=7" --dry-run
--all. --missing (thumbnails|previews|both). --threads N. --filter — Django queryset filter expression. --dry-run.

extract_metadata : Extract/parse media metadata (EXIF, container timestamps) for uploaded resources. Often the first remediation step when a batch of files came in without correct timestamps.

python manage.py extract_metadata --projects 7 --run --parse-timestamps
python manage.py extract_metadata --videos-only --max-workers 4
python manage.py extract_metadata --filter "deployment_id=42" --update-deployment
--projects N [N ...] — one or more project IDs, space-separated. --run — actually do the extraction (default is dry-run). --parse-timestamps. --update-deployment — sync date_recorded back into the Deployment timeline. --images-only / --videos-only (mutually exclusive). --max-workers (default 4), --filter.

delete_orphaned : Find and delete media files on disk not referenced by any Resource row. Use after manually deleting Resources or recovering from a partial restore.

python manage.py delete_orphaned --info     # dry-run report
python manage.py delete_orphaned            # actually delete

Server

start_uploader_server : Start the chunked-HTTP-upload FastAPI service (the Compose trapper_uploader container runs this). Listens on 0.0.0.0:8088 by default. Only run manually when developing the uploader code outside Compose.

python manage.py start_uploader_server

Admin actions reference

Every admin action in the Expert backend (/admin/), grouped by app.

accounts

Action What it does
set_user_roles_action Assign Research / Classification project roles to selected users; optional activation.
create_ftp_users_action Create Pure-FTPd accounts for selected users.
delete_ftp_users_action Remove Pure-FTPd access for selected users.
mail_users_action Send a custom email to selected users.
mask_selected_users PII-aware "delete": anonymizes the user row instead of cascading a real delete.

common

Action What it does
clear_gdpr Clear all users' GDPR consents.
clear_tos Clear all users' Terms of Service consents.
clear_both_consents Clear both GDPR and ToS consents.

storage

Action What it does
generate_missing_thumbnails_for_collections Async thumbnails for Resources in the selected Collections.
set_owner_managers_action Bulk-change owner/managers on selected Resources.
generate_missing_thumbnails (global) Same, but over all Resources.

media_classification

Action What it does
rerun_ai_pipeline (on ClassificationProjectCollection) Re-submit AI inference jobs for the selected (project × collection) pairs.
create_classificator_from_species_mapping (on AIProvider) Generate a Classificator from this provider's species mapping.
clone_provider (on AIProvider) Create an editable copy with keep_synced=False.
update_status (on AIClassificationJob) Re-fetch remote AI Manager status.
reparse_results (on AIClassificationJob) Reset to fetch_results and retry.

geomap

Action What it does
delete_deployments_with_related_data Cascade-delete deployment + descendants (Location preserved).
rerun_depth_calibration Re-fit CalibrationModel for selected calibration deployments.
rerun_distance_estimation Re-run distance estimation on selected deployments with optional overrides.

extra_tables

Action / view What it does
import_gbif_taxonomy (header action) Import/update Species rows from the bundled GBIF Backbone CSVs.