Basic MVP code that exposes a REST API for Tangara's air quality sensors, which are installed throughout Cali, Colombia.
Please read and execute each step below:
Create and use Python virtual environment:
$promt> python -m venv .venv
$promt> source .venv/bin/activate
Install all Python requirements:
$promt> python -m pip install -U pip
$promt> pip install -r requirements.txt
Generate a requirements file and then install from it in another environment:
$promt> pip freeze > requirements.txt
There is an SQLite database available to use out of the box.
All entities, relations and data are ready to use from the SQLite database file located in ./db/tangara-mvp.db and you don't need to change anything, because the API REST uses this SQLite database.
Optional, if you need to explore the database, I recommend you use: DB Browser for SQLite because it is easy to use, all that you need to do is open the SQLite database file from DB Browser and that's all.
Also, there are JSON ./db/json/ and CSV ./db/csv/ files for each entity on the database, therefore you can use the data for your own project, we support open knowledge that's important to the community open source.
Finally, we have exported an SQL file ./db/tangara-mvp.sql to recreate all the entities of our database in another SQL engine, like PostgreSQL or MySQL.
Jupyter Notebooks are helpful to explore some features and explain them to the team and easy to use before coding those features into the API, the purpose of the notebooks created in ./notebooks is only to explore, test, and explain those features to the team. You dont need change anything here.
Redis is an open source (BSD licensed), in-memory data structure store used as a database, cache, message broker, and streaming engine.
In development mode we need to install Redis CLI to debug our code and do some test. We will use Redis Server on a Docker configuration, that will be explaned later.
Downloading the source files:
$promt> wget https://download.redis.io/redis-stable.tar.gz
Compiling Redis CLI:
$promt> tar -xzvf redis-stable.tar.gz
$promt> cd redis-stable/
$promt> make redis-cli
Installing Redis CLI:
$promt> sudo cp src/redis-cli /usr/local/bin/
Connecting to the Redis server locally:
$promt> redis-cli -h 0.0.0.0 -p 6379
In development mode we are going to use a Docker container, to achieve that, we need just download the official Redis Docker Image, then we run a docker command to run a Redis Server container.
Downloading the official Redis Docker image:
$promt> docker pull redis:7-alpine
Run Redis Server container:
$promt> docker run --name tangara-redis -p 6379:6379 -d redis:7-alpine
Finally, we are ready to use a Redis Server in our project.
Development Mode
$promt> uvicorn app.main:app --reload
$promt> pytest -v -s -W ignore::trio.TrioDeprecationWarning -W ignore::DeprecationWarning
That's all for now ...