Use python version 3.10 for development.
pyenv is the recommended method to install and manage python versions.
python -m venv venv/
source venv/bin/activate
python -m pip install pip-tools
python -m pip install -e ".[testing]"
pre-commit install
-
Select
Module name:from the drop list for the first field and enteranalysis.cli -
In the
Parameters:field enterrun-analysis --date=2022-11-15 ./config_files(any date can be specified) -
In the
Environment variables:field enterPYTHONUNBUFFERED=1;SLACK_BOT_TOKEN=<slackbot_token>;GOOGLE_APPLICATION_CREDENTIALS=<service account file>;DEV_REPORT_SLACK_CHANNEL=overwatch-mvpContact gleonard@mozilla.com for SLACK_BOT_TOKEN
DO NOT UPDATE requirements.txt or requirements.in manually!
-
If you have not set up your local environment run the steps described above.
-
Activate your local environment in not already activated.
source venv/bin/activate
-
Make required changes to
pyproject.toml -
Generate a new version of requirements.in and requirements.txt and apply updated requirements.txt to venv.
make update_deps
To run pytest:
make local_test
Pytest is configured to also run black and flake8. Formatting failures are treated as test failures.
When building the docker image set the following environment variable to indicate the version
IMAGE_VERSION=<version>
If IMAGE_VERSION is not set the default value is <username>-dev (e.g. gleonard-dev) is used
To build a docker image run:
make image
To update environment, run pytest and build a new image run:
make build
After building the docker image, use the following command to launch the container. make run is
configured to publish reports to the development #overwatch-mvp Slack channel instead of the production
Slack channel #overwatch-reports
make run RUN_DATE=<YYYY-MM-DD> CREDENTIAL_VOLUME_MOUNT=<location of service account file> DESTINATION_CREDENTIAL_FILENAME=<service_account_filename>.json SLACK_BOT_TOKEN=<slackbot_token>
To run the docker image with access to a shell prompt use (generally for debugging purposes):
make shell
To stop the docker container:
make stop
Testing Overwatch with Airflow can be accomplished by running Airflow locally. Follow the steps outlined in https://mana.mozilla.org/wiki/pages/viewpage.action?spaceKey=SRE&title=WTMO+Developer+Guide to set up Airflow
- The Container Registry in the
automated-analysis-devproject has been enabled (https://console.cloud.google.com/gcr/images/automated-analysis-dev?project=automated-analysis-dev). This is where development images are pushed and pulled. To push a development docker image use (see IMAGE_VERSION notes above).
make dev_push
-
Launch airflow and create gke (see https://mana.mozilla.org/wiki/pages/viewpage.action?spaceKey=SRE&title=WTMO+Developer+Guide)
-
Create the following Variables in Airflow:
overwatch_slack_tokenand set the value to the Slack token (contact gleonard@mozilla.com for access).overwatch_image_versionand set to the value of IMAGE_VERSION or<username>-devif IMAGE_VERSION is not set
-
Update your local copy of overwatch.py DAG in
telemetry-airflowwith the following changes:- image repository - replace
moz-fx-data-airflow-prod-88e0withautomated-analysis-dev - report slack channel - add
"DEV_REPORT_SLACK_CHANNEL" "overwatch-mvp"toenv_varsdict forGKEPodOperator - add GCP dev GKE cluster settings to
GKEPodOperator(replacing with your username:- gcp_conn_id="google_cloud_gke_sandbox",
- project_id="moz-fx-data-gke-sandbox",
- cluster_name="-gke-sandbox",
- location="us-west1",
- image repository - replace
