Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit 3984132

Browse files
authored
Merge pull request #18 from Worth-NL/PatchingUp
Patching up
2 parents 673166d + 5e25e8b commit 3984132

File tree

5 files changed

+24
-109
lines changed

5 files changed

+24
-109
lines changed

app/__init__.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -308,22 +308,6 @@ def register_v2_blueprints(application):
308308

309309

310310
def init_app(app):
311-
from opencensus.ext.azure.trace_exporter import AzureExporter
312-
from opencensus.ext.flask.flask_middleware import FlaskMiddleware
313-
from opencensus.trace.samplers import ProbabilitySampler
314-
315-
def callback_function(envelope):
316-
envelope.tags["ai.cloud.role"] = "api"
317-
318-
azure_exporter = AzureExporter()
319-
azure_exporter.add_telemetry_processor(callback_function)
320-
321-
FlaskMiddleware(
322-
app,
323-
exporter=azure_exporter,
324-
sampler=ProbabilitySampler(rate=1.0),
325-
)
326-
327311
@app.before_request
328312
def record_request_details():
329313
CONCURRENT_REQUESTS.inc()

docs/instructions.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,31 @@ This file contains all the instructions required to run the `api` locally. In ad
44

55
## Prerequisites
66

7-
* Docker Desktop ([instructions for Mac](https://docs.docker.com/desktop/install/mac-install/))
8-
* PostgreSQL 11 (for Mac, run in a terminal `$ brew install postgresql@11`)
9-
* pgAdmin4 ([link for Mac](https://www.pgadmin.org/download/pgadmin-4-macos/))
10-
* AWS CLI (for Mac, run in a terminal `$ brew install awscli`)
11-
* Python 3.9 (if you want/need to run the api not in Docker)
7+
- Docker Desktop ([instructions for Mac](https://docs.docker.com/desktop/install/mac-install/))
8+
- PostgreSQL 11 (for Mac, run in a terminal `$ brew install postgresql@11`)
9+
- pgAdmin4 ([link for Mac](https://www.pgadmin.org/download/pgadmin-4-macos/))
10+
- AWS CLI (for Mac, run in a terminal `$ brew install awscli`)
11+
- Python 3.9 (if you want/need to run the api not in Docker)
1212

1313
## AWS configuration
1414

1515
Current implementation of the notifications app makes use of several AWS resources. These were created in an AWS account which belongs to Ernout.
1616

1717
The following resources were created:
1818

19-
* SES
20-
* S3 buckets
19+
- SES
20+
- S3 buckets
2121

2222
If a new sandbox (non-production) AWS SES is to be setup, the following is most likely necessary:
23+
2324
> "You need to set up the email address you want to mail to in amazon - I don't know why. So I authorized emailing to my email address through amazon's web ui." - Ernout
2425
2526
For application to be able to communicate with AWS APIs, it needs API keys. Ask your fellow teammates for the keys and do the following:
2627

2728
1. In the home directory create `.aws` folder.
2829
1. In `~/.aws/` create file “credentials” (no extension)
2930
1. Place the following two rows in the file
31+
3032
```
3133
aws_access_key_id=<KEY_ID_YOU_GOT>
3234
aws_secret_access_key=<ACCESS_KEY_YOU_GOT>
@@ -44,13 +46,13 @@ aws_secret_access_key=<ACCESS_KEY_YOU_GOT>
4446

4547
The following changes must be made to the database:
4648

47-
| Table | Column | Row | New value | Comment |
48-
|---|---|---|---|---|
49-
| `services` | `email_from` | | `noreply` | necessary for emails sending. `noreply` is the part of email address before `@` |
50-
| `domain` | `domain` | | `worth.systems` | if you want to create account using `worth.systems` email address. For `organisation_id` use an existing one in `organisation` table or create a new organisation |
51-
| `provider_details` | `support_international` | `Firetext` | `true` | necessary for sms sending |
52-
| `provider_details` | `active` | `mmg` | `false` | necessary for sms sending |
53-
| `service_sms_senders` | `sms_sender` | all rows | `NotifyNL` | necessary for sms sending. This one is important not to miss. If `GOVUK` is used as `sms_sender`, app will get blocked from being able to send sms |
49+
| Table | Column | Row | New value | Comment |
50+
| --------------------- | ----------------------- | ---------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
51+
| `services` | `email_from` | | `noreply` | necessary for emails sending. `noreply` is the part of email address before `@` |
52+
| `domain` | `domain` | | `worth.systems` | if you want to create account using `worth.systems` email address. For `organisation_id` use an existing one in `organisation` table or create a new organisation |
53+
| `provider_details` | `support_international` | `Firetext` | `true` | necessary for sms sending |
54+
| `provider_details` | `active` | `mmg` | `false` | necessary for sms sending |
55+
| `service_sms_senders` | `sms_sender` | all rows | `NotifyNL` | necessary for sms sending. This one is important not to miss. If `GOVUK` is used as `sms_sender`, app will get blocked from being able to send sms |
5456

5557
## Running app
5658

@@ -60,6 +62,7 @@ Follow the following steps to get the `Api` running locally in a Docker containe
6062
1. Start PostgreSQL 11
6163
1. Ask your fellow teammates for `FIRETEXT_API_KEY` and `FIRETEXT_INTERNATIONAL_API_KEY`
6264
1. In the root of the repo create `environment.sh` with the following content
65+
6366
```
6467
export NOTIFY_ENVIRONMENT='development'
6568
@@ -73,18 +76,14 @@ export NOTIFICATION_QUEUE_PREFIX='YOUR_OWN_PREFIX'
7376
export FLASK_APP=application.py
7477
export FLASK_DEBUG=1
7578
export WERKZEUG_DEBUG_PIN=off
76-
77-
export APPLICATIONINSIGHTS_ENABLED=1
78-
export APPLICATIONINSIGHTS_CONNECTION_STRING=<InstrumentationKey>
7979
```
80-
1. Ask your team for correct `<InstrumentationKey>`
80+
8181
1. Open a terminal in the root of the repo and run `$ make bootstrap-with-docker` to create the docker image
8282
1. Run `$ make run-migrations-with-docker` to run migrations for the database
8383
1. Run `$ make run-flask-with-docker`
8484
1. Open another terminal and run `$ make run-celery-with-docker`. This worker will handle the notifications
8585
1. The `api` is now available at `localhost:6011`
8686

87-
8887
## Troubleshooting
8988

9089
### `$ make run-migrations-with-docker` fails with Error 1
@@ -93,4 +92,4 @@ Make sure you added AWS credentials. See [AWS configuration](#aws-configuration)
9392

9493
### `too many verify codes created` error
9594

96-
Empty the `verify_code` table in the database.
95+
Empty the `verify_code` table in the database.

requirements.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,3 @@ prometheus-client==0.14.1
3434
git+https://github.com/alphagov/gds_metrics_python.git@6f1840a57b6fb1ee40b7e84f2f18ec229de8aa72
3535

3636
sentry-sdk[flask,celery,sqlalchemy]>=1.0.0,<2.0.0
37-
38-
opencensus-ext-azure
39-
opencensus-ext-flask

requirements.txt

Lines changed: 5 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ awscli==1.29.5
1818
# via awscli-cwlogs
1919
awscli-cwlogs==1.4.6
2020
# via -r requirements.in
21-
azure-core==1.29.3
22-
# via
23-
# azure-identity
24-
# opencensus-ext-azure
25-
azure-identity==1.14.0
26-
# via opencensus-ext-azure
2721
bcrypt==4.0.0
2822
# via flask-bcrypt
2923
beautifulsoup4==4.11.1
@@ -47,7 +41,6 @@ botocore==1.31.5
4741
cachetools==5.2.0
4842
# via
4943
# -r requirements.in
50-
# google-auth
5144
# notifications-utils
5245
celery[sqs]==5.2.7
5346
# via
@@ -59,9 +52,7 @@ certifi==2023.7.22
5952
# requests
6053
# sentry-sdk
6154
cffi==1.15.1
62-
# via
63-
# -r requirements.in
64-
# cryptography
55+
# via -r requirements.in
6556
charset-normalizer==2.1.1
6657
# via requests
6758
click==8.1.3
@@ -82,11 +73,6 @@ click-repl==0.2.0
8273
# via celery
8374
colorama==0.4.4
8475
# via awscli
85-
cryptography==41.0.3
86-
# via
87-
# azure-identity
88-
# msal
89-
# pyjwt
9076
dnspython==2.2.1
9177
# via eventlet
9278
docopt==0.6.2
@@ -105,7 +91,6 @@ flask==2.3.2
10591
# flask-sqlalchemy
10692
# gds-metrics
10793
# notifications-utils
108-
# opencensus-ext-flask
10994
# sentry-sdk
11095
flask-bcrypt==1.0.1
11196
# via -r requirements.in
@@ -125,12 +110,6 @@ gds-metrics @ git+https://github.com/alphagov/gds_metrics_python.git@6f1840a57b6
125110
# via -r requirements.in
126111
geojson==2.5.0
127112
# via notifications-utils
128-
google-api-core==2.11.1
129-
# via opencensus
130-
google-auth==2.22.0
131-
# via google-api-core
132-
googleapis-common-protos==1.60.0
133-
# via google-api-core
134113
govuk-bank-holidays==0.11
135114
# via notifications-utils
136115
greenlet==1.1.3
@@ -186,26 +165,10 @@ marshmallow-sqlalchemy==0.28.1
186165
# via -r requirements.in
187166
mistune==0.8.4
188167
# via notifications-utils
189-
msal==1.23.0
190-
# via
191-
# azure-identity
192-
# msal-extensions
193-
msal-extensions==1.0.0
194-
# via azure-identity
195168
notifications-python-client==8.0.1
196169
# via -r requirements.in
197170
notifications-utils @ git+https://github.com/Worth-NL/[email protected]
198171
# via -r requirements.in
199-
opencensus==0.11.2
200-
# via
201-
# opencensus-ext-azure
202-
# opencensus-ext-flask
203-
opencensus-context==0.1.3
204-
# via opencensus
205-
opencensus-ext-azure==1.1.9
206-
# via -r requirements.in
207-
opencensus-ext-flask==0.8.2
208-
# via -r requirements.in
209172
orderedset==2.0.3
210173
# via notifications-utils
211174
packaging==21.3
@@ -215,36 +178,23 @@ packaging==21.3
215178
# marshmallow-sqlalchemy
216179
phonenumbers==8.13.18
217180
# via notifications-utils
218-
portalocker==2.7.0
219-
# via msal-extensions
220181
prometheus-client==0.14.1
221182
# via
222183
# -r requirements.in
223184
# gds-metrics
224185
prompt-toolkit==3.0.31
225186
# via click-repl
226-
protobuf==4.24.1
227-
# via
228-
# google-api-core
229-
# googleapis-common-protos
230-
psutil==5.9.5
231-
# via opencensus-ext-azure
232187
psycopg2-binary==2.9.3
233188
# via -r requirements.in
234189
pyasn1==0.4.8
235-
# via
236-
# pyasn1-modules
237-
# rsa
238-
pyasn1-modules==0.3.0
239-
# via google-auth
190+
# via rsa
240191
pycparser==2.21
241192
# via cffi
242193
pycurl==7.44.1
243194
# via kombu
244-
pyjwt[crypto]==2.5.0
195+
pyjwt==2.5.0
245196
# via
246197
# -r requirements.in
247-
# msal
248198
# notifications-python-client
249199
pyparsing==3.0.9
250200
# via packaging
@@ -274,21 +224,15 @@ redis==4.5.4
274224
requests==2.31.0
275225
# via
276226
# awscli-cwlogs
277-
# azure-core
278-
# google-api-core
279227
# govuk-bank-holidays
280-
# msal
281228
# notifications-python-client
282229
# notifications-utils
283-
# opencensus-ext-azure
284230
rfc3339-validator==0.1.4
285231
# via jsonschema
286232
rfc3987==1.3.8
287233
# via jsonschema
288234
rsa==4.7.2
289-
# via
290-
# awscli
291-
# google-auth
235+
# via awscli
292236
s3transfer==0.6.0
293237
# via
294238
# awscli
@@ -302,11 +246,9 @@ shapely==1.8.4
302246
six==1.16.0
303247
# via
304248
# awscli-cwlogs
305-
# azure-core
306249
# click-repl
307250
# eventlet
308251
# flask-marshmallow
309-
# google-auth
310252
# python-dateutil
311253
# rfc3339-validator
312254
smartypants==2.0.1
@@ -322,18 +264,13 @@ sqlalchemy==1.4.41
322264
# sentry-sdk
323265
statsd==3.3.0
324266
# via notifications-utils
325-
types-cryptography==3.3.23.2
326-
# via pyjwt
327267
typing-extensions==4.7.1
328-
# via
329-
# azure-core
330-
# pypdf
268+
# via pypdf
331269
uri-template==1.2.0
332270
# via jsonschema
333271
urllib3==1.26.12
334272
# via
335273
# botocore
336-
# google-auth
337274
# kombu
338275
# requests
339276
# sentry-sdk

scripts/run_locally_with_docker.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ docker run -it --rm \
3737
-e FLASK_APP=$FLASK_APP \
3838
-e FLASK_DEBUG=$FLASK_DEBUG \
3939
-e WERKZEUG_DEBUG_PIN=$WERKZEUG_DEBUG_PIN \
40-
-e APPLICATIONINSIGHTS_ENABLED=$APPLICATIONINSIGHTS_ENABLED \
41-
-e APPLICATIONINSIGHTS_CONNECTION_STRING=$APPLICATIONINSIGHTS_CONNECTION_STRING \
4240
${EXPOSED_PORTS} \
4341
-v $(pwd):/home/vcap/app \
4442
${DOCKER_IMAGE_NAME} \

0 commit comments

Comments
 (0)