Skip to content

Available commands

Various operations can be run on Panoramax API using its command line tool: migrate or clean-up database, authentication token handling, sequence management...

Database migration

As Panoramax is actively developed, when updating from a previous version, some database migration could be necessary. If so, when starting Panoramax, an error message will show up and warn about necessary migration. The following command has to be ran:

flask db upgrade
docker run --rm panoramax/api db-upgrade

✨ Database migrations should be handled automatically in the different docker compose by the migrations service

Rollback

There might be no reason to do so, but if necessary, a migration rollback can also be done:

flask db rollback
docker run --rm --entrypoint bash panoramax/api -c 'python3 -m flask db rollback'
docker compose run --rm --entrypoint bash migrations -c 'python3 -m flask db rollback' 

Note

A full database rollback (ie. removing all structures and data created by Panoramax API) can also be done by adding --all to the rollback command.

Force pictures heading in sequence

Since version 1.4.0, you can import pictures without heading metadata. By default, heading is computed based on sequence movement path (looking in front), but you can edit manually after import using this command:

flask set-sequences-heading \
--value <DEGREES_ROTATION_FROM_FORWARD> \
--overwrite \
<SEQUENCE_ID_1> <SEQUENCE_ID_2> ...
docker run --rm --entrypoint bash panoramax/api -c 'python3 -m flask set-sequences-heading --value <DEGREES_ROTATION_FROM_FORWARD> --overwrite <SEQUENCE_ID_1> <SEQUENCE_ID_2> ...'
docker compose run --rm --entrypoint bash api -c 'python3 -m flask set-sequences-heading --value <DEGREES_ROTATION_FROM_FORWARD> --overwrite <SEQUENCE_ID_1> <SEQUENCE_ID_2> ...'

Cached data

Some data is cached (using materialized views) in database for a better performance.

If you use background workers (and you should on a production-grade instance), they will do this regularly (based on the PICTURE_PROCESS_REFRESH_CRON parameter). Else you have to run from time to time the flask db refresh command to keep these views up-to-date. This can be run regularly using cron for example.

Clean-up

Eventually, if you want to clear database and delete derivate versions of pictures files (it doesn't delete original pictures), you can use the cleanup command:

flask cleanup
docker run --rm --entrypoint bash panoramax/api -c 'python3 -m flask cleanup'
docker compose run --rm --entrypoint bash api -c 'python3 -m flask cleanup'

You can cleanup only certain sequences:

flask cleanup <SEQUENCE_ID_1> <SEQUENCE_ID_2> ...
docker run --rm --entrypoint bash panoramax/api -c 'python3 -m flask cleanup <SEQUENCE_ID_1> <SEQUENCE_ID_2> ...'
docker compose run --rm --entrypoint bash api -c 'python3 -m flask cleanup <SEQUENCE_ID_1> <SEQUENCE_ID_2> ...'

You can also run some partial cleaning with the same cleanup command and one of the following options:

flask cleanup --database (1) --cache (2) --permanent-pictures (3)
  1. Removes entries from database
  2. Removes picture derivates (tiles, SD and thumbnail)
  3. Removes permanent (original) pictures
docker run --rm --entrypoint bash panoramax/api -c 'python3 -m flask cleanup --database (1) --cache (2) --permanent-pictures (3)'
  1. Removes entries from database
  2. Removes picture derivates (tiles, SD and thumbnail)
  3. Removes permanent (original) pictures
docker compose run --rm --entrypoint bash api -c 'python3 -m flask cleanup --database (1) --cache (2) --permanent-pictures (3)'
  1. Removes entries from database
  2. Removes picture derivates (tiles, SD and thumbnail)
  3. Removes permanent (original) pictures

Sequences reorder

You can sort all sequences by pictures capture time with the following command:

flask sequences reorder
docker run --rm --entrypoint bash panoramax/api -c 'python3 -m flask sequences reorder'
docker compose run --rm --entrypoint bash api -c 'python3 -m flask sequences reorder'

If you want to reorder some specific sequences, you need their ID (the UUID):

flask sequences reorder <SEQUENCE_ID_1> <SEQUENCE_ID_2>
docker run --rm --entrypoint bash panoramax/api -c 'python3 -m flask sequences reorder <SEQUENCE_ID_1> <SEQUENCE_ID_2>'
docker compose run --rm --entrypoint bash api -c 'python3 -m flask sequences reorder <SEQUENCE_ID_1> <SEQUENCE_ID_2>'

JWT token for the instance administrator

An instance administrator can get the JWT token of the default instance's account with the flask command default-account-tokens get.

flask default-account-tokens get
docker run --rm --entrypoint bash panoramax/api -c 'python3 -m flask default-account-tokens get'
docker compose run --rm --entrypoint bash api -c 'python3 -m flask default-account-tokens get'

This token can then be used to authenticate api calls as bearer token. This is especially useful when running an instance without an OAuth provider.

Check the API authentication section to know more what you can do with this token.

Warning

The instance need to be configured with a valid FLASK_SECRET_KEY for this to work (cf instance configuration). Be sure not to share this token!