Listens to SNEWS detector messages and writes to Postgres database
This packages provides a Python API and CLI to write observation messages to the persistent SNEWS Postgres Database. The main components of the package are one, a docker setup for a Postgre database, and two, a function that listens to a Kafka pipeline for snews messages and then writes those messages to the Postgre database. The code for the Kafka pipeline listener can be found in snews_db/kafka_listener.py.
Note: Make sure your hop credentials are set up !!
Follow the instructions in the Publishing Tools Quick Start
Fire-Drills |
Also see this page |
snews_db allows for fire-drill mode, currently this is the default option. Later, it can be adjusted through firedrill_mode=True/False arguments in listener functions, and through --firedrill/--no-firedrill flags within the CLI tools. Make sure you have the correct permissions to subscribe to these firedrill channels. The snews_db CLI is explained in more detail in the CLI section below. |
- Install docker desktop if not already.
- Run
poetry lock
followed bypoetry install
to install all relevant packages. - Make sure in the
pyproject.toml
file that any snews dependency packages are installed in developer/editable mode. For instance, if you are also developing snews publisher tools, you want to make sure that you havesnews-pt = { path = "../SNEWS_Publishing_Tools", develop = true }
(note this path assumes you have the SNEWS_Publishing_Tools repo one level above your SNEWS_DB_PIPELINE repo). - Modify
test-config.env
insnews_db/tests/etc
with the Postgre configurations parameters you want to use. - Run
bash start_containers.sh
to start the docker container with the Postgre SQL database.
There also exists tools for command line interactions. These are explained in detail here;
SNEWS_DB also supports various tools via a CLI. For instance, to run the Kafka pipeline listener, run the following command
snews_db listen-to-detectors [--firedrill/--no-firedrill]
.
To run all test cases, simply run pytest
from the root directory of the repo.