Contains:
- the public-facing REST API for Notification built on the GOV.UK Notify platform, which teams can integrate with using their clients
- an internal-only REST API built using Flask to manage services, users, templates, etc (this is what the admin app talks to)
- asynchronous workers built using Celery to put things on queues and read them off to be processed, sent to providers, updated, etc
- We currently do not support sending of letters
- We currently do not receive a response if text messages were delivered or not
On OS X:
- Install PyEnv with Homebrew. This will preserve your sanity.
brew install pyenv
- Install Python 3.6.9 or whatever is the latest
pyenv install 3.6.9
- If you expect no conflicts, set
3.6.9
as you default
pyenv global 3.6.9
- Ensure it installed by running
python --version
if it did not, take a look here: pyenv/pyenv#660
- Install
virtualenv
:
pip install virtualenvwrapper
- Add the following to your shell rc file. ex:
.bashrc
or.zshrc
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source ~/.pyenv/versions/3.6.9/bin/virtualenvwrapper.sh
- Restart your terminal and make your virtual environtment:
mkvirtualenv -p ~/.pyenv/versions/3.6.9/bin/python notifications-api
- You can now return to your environment any time by entering
workon notifications-api
-
Install Postgres.app.
-
Create the database for the application
createdb --user=postgres notification_api
- Decrypt our existing set of environment variables
gcloud kms decrypt --project=[PROJECT_NAME] --plaintext-file=.env --ciphertext-file=.env.enc --location=global --keyring=[KEY_RING] --key=[KEY_NAME]
A sane set of defaults exists in .env.example
- Install all dependencies
pip3 install -r requirements.txt
- Generate the version file ?!?
make generate-version-file
- Run all DB migrations
flask db upgrade
- Run the service
flask run -p 6011 --host=0.0.0.0
15a. To test
pip3 install -r requirements_for_test.txt
make test
702C
code>
scripts/run_celery.sh
scripts/run_celery_beat.sh
This codebase is Python 3 only. At the moment we run 3.6.9 in production. You will run into problems if you try to use Python 3.4 or older, or Python 3.7 or newer.
requirements.txt
file is generated from the requirements-app.txt
in order to pin
versions of all nested dependencies. If requirements-app.txt
has been changed (or
we want to update the unpinned nested dependencies) requirements.txt
should be
regenerated with
make freeze-requirements
requirements.txt
should be committed alongside requirements-app.txt
changes.
Problem : E999 SyntaxError: invalid syntax
when running flake8
Solution : Check that you are in your correct virtualenv, with python 3.5 or 3.6
Problem:
/bin/sh: 1: Syntax error: "(" unexpected
make: *** [Makefile:31: freeze-requirements] Error 2
when running make freeze-requirements
Solution: Change /bin/sh
to /bin/bash
in the Makefile
Problem: ImportError: failed to find libmagic. Check your installation
Solution:Install libmagic
, ex: brew install libmagic
Problem: assert 'test_notification_api' in db.engine.url.database, 'dont run tests against main db
Solution: Do not specify a database in your .env
Problem: Messages are in the queue but not sending
Solution: Check that celery
is running.