Skip to content

The Pyrrha (created by Prometeo) solution application for determining thresholds in toxin exposure measured by the sensor device and sent to the cloud from the smartphone carried by the firefighters.

License

Notifications You must be signed in to change notification settings

Pyrrha-Platform/Pyrrha-Rules-Decision

Repository files navigation

Pyrrha rules and decision engine

License Slack

This repository contains the Pyrrha solution application for determining thresholds in toxin exposure measured by the sensor device and sent to the cloud from the Samsung smartphone carried by the firefighters.

This service wakes up every minute and calculates time-weighted average exposures for all firefighters and compares them to the configured limits.

Contents

Background

In this repository you'll find a solution that goes beyond just reading the real-time parts-per-million readings that come from the sensor. The code here assesses the cumulative effect of exposure by calculates short-term exposure and time-weighted averages over 10 minute, 30 minute, 60 minute, 4 hour, and 8 hours.

The goals for this project are to:

  • Present gas exposure information to firefighters in a way that is helpful and actionable
  • Use standard metrics for gas exposure that align with regulations and standards
  • Understand expectations across several regions (EU, US, Australia, etc)

Understanding the terminology

An excellent top-level summary is available from OSHA Environmental Compliance Systems.

That resource summarizes all the different standards into 3 main concepts. Generally speaking, PEL/TLV/REL have three subcategories:

  1. Time-weighted average (TWA) - for the whole workday.
  2. Ceiling value - should never be exceed at any time.
  3. Short term exposure limit (STEL) - the 10 or 15 min TWA concentration (not 8 hours).

Other useful information

Prerequisites

  1. Docker
  2. IBM CLI
  3. Kubectl
  4. Helm
  5. Skaffold

Run locally with Python

You can run this solution locally in docker as follows

  1. Set up environment variables in the src/.env file

  2. Install MariaDB locally

    1. Pull MariaDB from DockerHub

      docker pull mariadb 
    2. Run the image

      docker run --rm -p 3306:3306 --name pyrrha-mariadb -e MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=true -d mariadb
    3. Test the image - TBD

  3. Create Python virtual environment

    python3 -m venv python3
  4. Activate virtual environment

    source python3/bin/activate
  5. Run the application

    python src/core_decision_flask_app.py 8080
  6. You should see the following output

    starting application
    * Serving Flask app "core_decision_flask_app" (lazy loading)
    * Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
    * Debug mode: off
    * Running on <http://0.0.0.0:8080/> (Press CTRL+C to quit)

Run locally with Docker

  1. Build the image

    docker build . -t rulesdecision
  2. Run the image

    docker run -p8080:8080 -t rulesdecision
  3. You should see the application logs

    starting application
    * Serving Flask app "core_decision_flask_app" (lazy loading)
    * Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
    * Debug mode: off
    * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)

Run on Kubernetes

You can run this application on Kubernetes. The skaffold.yaml file let's you quickly run the application on the cluster by using Skaffold. There are two profiles provided. To run the solution on the test namespace use:

skaffold dev -p test

Troubleshooting

  1. Database does not connect

    1. ensure .env file has the correct values for database connection
  2. Change the db password

Built with

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting Pyrrha pull requests.

License

This project is licensed under the Apache 2 License - see the LICENSE file for details.

About

The Pyrrha (created by Prometeo) solution application for determining thresholds in toxin exposure measured by the sensor device and sent to the cloud from the smartphone carried by the firefighters.

Topics

Resources

License

Stars

Watchers

Forks