A dummy-simple API in front of garage for storing and accessing panoramas in MeshDB.
gunicorn main:app -b 0.0.0.0:8081
Pano keeps track of Images in Postgres. An Image has a uuid, a timestamp, an install_number, an order, and a category.
- UUID: Simple unique identifier
- Timestamp: When the image was uploaded
- Install Number: The Install # this image is associated with
- Order: What order clients should display this image in when querying for a specific install's images
- Category: An indicator of the image contents. A panorama with potential LOS, a photo of the equipment installed on the roof, or a notable detail about the building.
When querying for a Node with multiple installs, the Images from the lower install number are returned first
We should find some way to mark if a Node is visible in an Image. Maybe add a column for it Node Table, seen from: {uuid, uuid, uuid...}
We use garage to store images as objects. The schema for the path that identifies a particular object is very simple:
/<bucket name>/<install_number>/<uuid>
To upgrade your database with the latest changes, run the following:
alembic upgrade head
To create new migrations when the data model is changed, run a revision command like so:
alembic revision --autogenerate -m "initial revision"
Set up Database
docker exec -it meshdb-postgres-1 psql -U meshdb -d postgres
# CREATE USER pano SUPERUSER ENCRYPTED PASSWORD 'localdev';
# CREATE DATABASE pano;
Use a venv
pip install -e '.[dev]'
flask --app app run or gunicorn -w 4 'main:app'
Get a token by using jwt with your client name
python -c 'from dotenv import load_dotenv; import jwt; import os; load_dotenv(); print(jwt.encode({"client": "my_client"}, os.environ.get("PANO_SECRET_KEY"), algorithm="HS256"))'
The API Token needs Read Only, and the ability to Change Building
If you're getting 403's, check that you ran create_groups in your MeshDB Dev enviornment.
Garage has a slightly more involved setup than MinIO (whom we migrated off of due to becoming hostile to open source)
https://garagehq.deuxfleurs.fr/documentation/quick-start/
- Stand up Garage with this command
docker compose -f dev/docker-compose.yml up -d garage
- Get your node ID with this command
_Note that your container name might be different. Fetch it with docker ps
docker exec -it pano-dev-garage-1 /garage status
- Finally, apply a layout
docker exec -it pano-dev-garage-1 /garage layout assign -z dc1 -c 1G <node_id>
docker exec -it pano-dev-garage-1 /garage layout apply --version 1
- Also don't forget to let your key talk to the bucket
dev3 -n pano exec -it garage-0 -- /garage bucket allow \
--read \
--write \
--owner \
pano \
--key pano-app-key
Garage needs you to create a key with its API, so you'll have to deploy it, then go in and create the API key, and then set it in GitHub.
if you need to add an env var,
-
Add it to the Environment on Github as either a secret or a value
-
Add it to the
deploy-to-k8s.yamlfile under the appropriate deployment (pano or garage) -
Add it to the appropriate
configmap.yamlorsecrets.yamlfile.
in kube, it will be port 80
