Skip to content

Welthungerhilfe/cgm-rg

Repository files navigation

codecov

Child Growth Monitor Result Generation

Child Growth Monitor (CGM) is a game-changing app to detect malnutrition. If you have questions about the project, reach out to info@childgrowthmonitor.org.

Introduction

Result Generation is performed when the Scanner App takes a scan and uploads it using cgm-api. Result Generation plays a central role in generation of the accurate prediction of height, weight and MUAC for the scans collected from the scanner app. These generated results will be used by the tagging tool to inspect the scans and return the results to users which are accuracte.

For detailed explaination of data flow, one may look into wiki introduction

Supported Python versions:

  • 3.6
  • maybe 3.7

Branch Policy: See branch policy document and this internal documentation

Local Setup

Follow the steps in this wiki page: detailed setup of local development.

Models

For some parts of the code to work, you need ML models. You can either build them yourself using cgm-ml. However, for internal contributors we recommend to download existing models as follows:

  • Note that src/download_model.py helps to download models and uses environment variables

  • Internal contributors can get the environment variables, e.g. for the sandbox environment:

    • Go to <portal.azure.com>
    • Find the ACI (Azure container instance) for your environment, e.g. cgmbecidevrgaci for sandbox
    • On the left (in the Settings section), click Containers
    • Go to the Properties tab and copy the needed environment variables from here
    • Put the enviromentment into a file called env.list. Example (make sure to replace with actual variable values)
    SUB_ID=00000000-1111-2222-3333-444444444444
    TENANT_ID=00000000-1111-2222-3333-444444444444
    SP_ID=00000000-1111-2222-3333-444444444444
    SP_PASSWD=00000000-1111-2222-3333-444444444444
    

It can be helpful to run the local development using this command

docker run -it --rm --env-file ./env.list \
    -v $(pwd)/src:/app/src \
    -v $(pwd)/models:/app/models \
    --add-host="localhost:<YOUR IP>" \
    --name rg_service_1_0 rgservice:1.0

Deploying to an environment

e.g. Sandbox environment.

How to use/test

In order to use this you need a phone running the Scanner App. Inside the app, you can upload a sample scan using cgm app. Results will be generated and shown in the tagging tool. To debug you can also check the logs in the environment's ACI.

Versioning

This project is versioned according to CGM versioning rules. The version of the project can be found in a file called VERSION. The CI pipeline tags and pushes a patch version update automatically after a merge to the main branch.

The following utility scripts can be used to manipulate the version (requires bump2version):

# install bump2version
pip install bump2version

# Get the current version
head -n 1 VERSION

# Bump minor version (use major or patch to bump respective parts)
bumpversion minor

# Set a specific version. The `patch` argument does not affect the verions but is required.
bumpversion --new-version <version> patch

These utility command do not commit or tag the repository.

Flake 8 linting

Use below command to check and fix flake8 issue flake8 --ignore=E501,E402 autopep8 --in-place --aggressive --aggressive

For running cgm-rg locally, Below command can be helpful: docker build -t cgm-rg . docker run --env-file .env.docker --rm -it cgm-rg bash

Command to run result generation once from the container for testing. python src/result_gen_with_api.py >> debug_log.txt 2>&1

Test