Fast-API Response catalog for pre-computed query
Project description
Akvo-ResponseGrouper
Fast-API Response catalog for pre-computed query
Install
$ pip install AkvoResponseGrouper
Schema Requirements
Please follow the required schema before using AkvoResponseGrouper.
Usage
- Database Migration
Database migration is the first required step for AkvoResponseGrouper to work. Use the akvo-responsegrouper CLI to migrate all data sources with JSON configuration files to generate Materialized Views that AkvoResponseGrouper can then use.
$ akvo-responsegrouper
usage: akvo-responsegrouper [-h] [-c CONFIG] [-d]
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
akvo-responsegrouper -c <json_file_config>
-d, --drop Drop the ar_category view table
- Router
To get the new endpoint provided by AkvoResponseGrouper, import the collection route to the App by:
from fastapi import FastAPI
from AkvoResponseGrouper.routes import collection_route
app = FastAPI(
root_path="/",
title="Akvo Response Grouper Demo",
)
app.include_router(collection_route)
@app.get("/", tags=["Dev"])
def read_main():
return "OK"
- Query
Development
Run Dev Containers
The dev environment contains two containers: FastAPI backend and PostGres db, to run:
docker compose up -d
Before go to the next step, wait until the service started at http://localhost:5000.
Seed Necessary Data
In order to debug the data itself. We need to seed the example form and fake datapoints
docker compose exec backend python -m script.seeder_form
docker compose exec backend python -m script.seeder_datapoint <number_of_datapoint>
Migration
Dev environment uses contents that is available in Akvo-ResponseGrouper/src/AkvoResponseGrouper
. To create the Category Materialized View via CLI in dev environment:
Upgrade:
python -m AkvoResponseGrouper.cli.migrate -c './sources/category.json'
After upgrade, you can see "AkvoResponseGrouper - Collection" is available in API docs, ussualy http://locahhost:5000/docs (Depends on the root path api).
Downgrade:
python -m AkvoResponseGrouper.cli.migrate -c './sources/category.json'
Teardown
docker compose down -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for AkvoResponseGrouper-1.3.2a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e12eb0d7e92ab2e3a23b59be604cce1ba934a0824b23884bee6b936ea0a237dd |
|
MD5 | f2e1f3ccb49c176635858c4e562ddd0a |
|
BLAKE2b-256 | f9cec1d769ae5a896945f4a170c51b1f94fc152178f7a97b5dec26dc7ff91c30 |
Hashes for AkvoResponseGrouper-1.3.2a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cea8815fc6dbd7b2b6efd34a44a4bd718e7dc839533dce1333aa80bdaadd5d82 |
|
MD5 | a07c5a2c8d181ebc6202676d170909c8 |
|
BLAKE2b-256 | fddd454c0fd7569345895c9d90d3387b6377c2121ff694f63ae4e07c65b1af97 |