Skip to content

This repository contains functionality for checking questionnaire survey days and automating daybatch creation.

Notifications You must be signed in to change notification settings

ONSdigital/blaise-daybatch-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blaise-daybatch-functions

A day batch is a selection of cases from the entire Blaise data file that will be worked on that day. Since the CATI system cannot work without a day batch, you have to create a day batch per CATI survey for each active day in the survey period.

This repo has functions for creating daybatches and checking that daybatches have been created. Notifications are sent if daybatches don't exist but should. These functions are deployed to GCP as Cloud Functions and will be triggered via Cloud Scheduler.

An email will be sent to the users if Daybatch creation fails or there is no baybatch.

The email template comes from gov.notify portal (see Rich for credentials :eyes).

Email wording changed on 07/04/22 to "Questionnaire {questionnaire} may not have a daybatch".

Local Setup

Clone the project locally:

git clone https://github.com/ONSdigital/blaise-daybatch-functions.git

Setup a virtual environment:

macOS:

python3 -m venv venv
source venv/bin/activate

Windows:

python -m venv venv
venv\Scripts\activate

Install poetry:

pip install poetry

Install dependencies:

poetry install

Authenticate with GCP:

gcloud auth login

Set your GCP project:

gcloud config set project ons-blaise-v2-dev-sandbox123

Open a tunnel to our Blaise RESTful API in your GCP project:

gcloud compute start-iap-tunnel restapi-1 80 --local-host-port=localhost:90 --zone europe-west2-a

Create an .env file in the root of the project and add the following environment variables:

Variable Description Example
BLAISE_API_URL The RESTful API URL the application will use to get installed questionnaire data. localhost:90
BLAISE_SERVER_PARK The name of the Blaise server park. gusty
NOTIFY_API_KEY The API key for the GOV.UK Notify service. blah-blah-blah
TO_NOTIFY_EMAIL The email address to notify when a daybatch doesn't exist but should. blah@blah.blah

Example .env file:

BLAISE_API_URL="localhost:90"
BLAISE_SERVER_PARK="gusty"
NOTIFY_API_KEY="blah-blah-blah"
TO_NOTIFY_EMAIL="blah@blah.blah"

The local environment variables aren't necessary if you're only running the unit tests and the behave tests.

Run the "create_daybatches" Cloud Function:

poetry run python -c "from main import create_daybatches; create_daybatches(None, None)"

Run the "check_daybatches" Cloud Function:

poetry run python -c "from main import check_daybatches; check_daybatches(None, None)"

Run Unit Tests

poetry run python -m pytest

Run Behave BDD Tests

poetry run python -m behave tests/features

About

This repository contains functionality for checking questionnaire survey days and automating daybatch creation.

Resources

Stars

Watchers

Forks

Contributors 8