Skip to content

Commit 41ecf8c

Browse files
authored
Merge pull request #1853 from GSA/main
7-22-2025 Production Deploy
2 parents 62ab4ee + cfbf2b9 commit 41ecf8c

39 files changed

+1934
-913
lines changed

.coveragerc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[report]
2+
exclude_lines =
3+
pragma: no cover
4+
^\s*logger\.
5+
^\s*current_app\.logger\.

.ds.baseline

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
"filename": "tests/app/dao/test_services_dao.py",
230230
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
231231
"is_verified": false,
232-
"line_number": 289,
232+
"line_number": 290,
233233
"is_secret": false
234234
}
235235
],
@@ -267,15 +267,15 @@
267267
"filename": "tests/app/notifications/test_receive_notification.py",
268268
"hashed_secret": "913a73b565c8e2c8ed94497580f619397709b8b6",
269269
"is_verified": false,
270-
"line_number": 27,
270+
"line_number": 28,
271271
"is_secret": false
272272
},
273273
{
274274
"type": "Base64 High Entropy String",
275275
"filename": "tests/app/notifications/test_receive_notification.py",
276276
"hashed_secret": "d70eab08607a4d05faa2d0d6647206599e9abc65",
277277
"is_verified": false,
278-
"line_number": 57,
278+
"line_number": 58,
279279
"is_secret": false
280280
}
281281
],
@@ -295,7 +295,7 @@
295295
"filename": "tests/app/service/test_rest.py",
296296
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
297297
"is_verified": false,
298-
"line_number": 1282,
298+
"line_number": 1288,
299299
"is_secret": false
300300
}
301301
],
@@ -339,7 +339,7 @@
339339
"filename": "tests/app/user/test_rest.py",
340340
"hashed_secret": "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
341341
"is_verified": false,
342-
"line_number": 864,
342+
"line_number": 874,
343343
"is_secret": false
344344
}
345345
],
@@ -374,5 +374,5 @@
374374
}
375375
]
376376
},
377-
"generated_at": "2025-06-09T16:07:54Z"
377+
"generated_at": "2025-07-02T18:56:01Z"
378378
}

.github/dependabot.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ updates:
1313
- "dependabot" # Custom label to identify Dependabot PRs
1414
assignees:
1515
- "alexjanousekGSA"
16-
reviewers:
17-
- "alexjanousekGSA"

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ run-celery: ## Run celery, TODO remove purge for staging/prod
7070
-A run_celery.notify_celery worker \
7171
--pidfile="/tmp/celery.pid" \
7272
--loglevel=INFO \
73-
--pool=threads
74-
--concurrency=10
73+
--pool=eventlet
74+
--concurrency=20
7575

7676

7777
.PHONY: dead-code
@@ -104,8 +104,8 @@ test: ## Run tests and create coverage report
104104
poetry run isort ./app ./tests
105105
poetry run coverage run --omit=*/migrations/*,*/tests/* -m pytest --maxfail=10
106106

107-
## TODO set this back to 95 asap
108-
poetry run coverage report -m --fail-under=93
107+
108+
poetry run coverage report -m --fail-under=95
109109
poetry run coverage html -d .coverage_cache
110110

111111
.PHONY: test-debug

app/aws/s3.py

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from app.clients import AWS_CLIENT_CONFIG
1414

1515
# from app.service.rest import get_service_by_id
16+
from app.utils import hilite
1617
from notifications_utils import aware_utcnow
1718

1819
FILE_LOCATION_STRUCTURE = "service-{}-notify/{}.csv"
@@ -22,11 +23,6 @@
2223
ttl = 60 * 60 * 24 * 7
2324

2425

25-
# Global variable
26-
s3_client = None
27-
s3_resource = None
28-
29-
3026
def get_service_id_from_key(key):
3127
key = key.replace("service-", "")
3228
key = key.split("/")
@@ -69,32 +65,31 @@ def clean_cache():
6965

7066

7167
def get_s3_client():
72-
global s3_client
73-
if s3_client is None:
74-
access_key = current_app.config["CSV_UPLOAD_BUCKET"]["access_key_id"]
75-
secret_key = current_app.config["CSV_UPLOAD_BUCKET"]["secret_access_key"]
76-
region = current_app.config["CSV_UPLOAD_BUCKET"]["region"]
77-
session = Session(
78-
aws_access_key_id=access_key,
79-
aws_secret_access_key=secret_key,
80-
region_name=region,
81-
)
82-
s3_client = session.client("s3", config=AWS_CLIENT_CONFIG)
68+
69+
access_key = current_app.config["CSV_UPLOAD_BUCKET"]["access_key_id"]
70+
secret_key = current_app.config["CSV_UPLOAD_BUCKET"]["secret_access_key"]
71+
region = current_app.config["CSV_UPLOAD_BUCKET"]["region"]
72+
session = Session(
73+
aws_access_key_id=access_key,
74+
aws_secret_access_key=secret_key,
75+
region_name=region,
76+
)
77+
current_app.logger.info(hilite("About to call session.client"))
78+
s3_client = session.client("s3", config=AWS_CLIENT_CONFIG)
79+
current_app.logger.info(hilite("SESSION CALLED"))
8380
return s3_client
8481

8582

8683
def get_s3_resource():
87-
global s3_resource
88-
if s3_resource is None:
89-
access_key = current_app.config["CSV_UPLOAD_BUCKET"]["access_key_id"]
90-
secret_key = current_app.config["CSV_UPLOAD_BUCKET"]["secret_access_key"]
91-
region = current_app.config["CSV_UPLOAD_BUCKET"]["region"]
92-
session = Session(
93-
aws_access_key_id=access_key,
94-
aws_secret_access_key=secret_key,
95-
region_name=region,
96-
)
97-
s3_resource = session.resource("s3", config=AWS_CLIENT_CONFIG)
84+
access_key = current_app.config["CSV_UPLOAD_BUCKET"]["access_key_id"]
85+
secret_key = current_app.config["CSV_UPLOAD_BUCKET"]["secret_access_key"]
86+
region = current_app.config["CSV_UPLOAD_BUCKET"]["region"]
87+
session = Session(
88+
aws_access_key_id=access_key,
89+
aws_secret_access_key=secret_key,
90+
region_name=region,
91+
)
92+
s3_resource = session.resource("s3", config=AWS_CLIENT_CONFIG)
9893
return s3_resource
9994

10095

app/celery/nightly_tasks.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from app.aws.s3 import remove_csv_object
99
from app.celery.process_ses_receipts_tasks import check_and_queue_callback_task
1010
from app.config import QueueNames
11-
from app.cronitor import cronitor
1211
from app.dao.fact_processing_time_dao import insert_update_processing_time
1312
from app.dao.inbound_sms_dao import delete_inbound_sms_older_than_retention
1413
from app.dao.jobs_dao import (
@@ -30,8 +29,7 @@
3029
from app.utils import get_midnight_in_utc, utc_now
3130

3231

33-
@notify_celery.task(name="remove_sms_email_jobs")
34-
@cronitor("remove_sms_email_jobs")
32+
@notify_celery.task(name="remove-sms-email-jobs")
3533
def remove_sms_email_csv_files():
3634
_remove_csv_files([NotificationType.EMAIL, NotificationType.SMS])
3735

@@ -51,6 +49,7 @@ def cleanup_unfinished_jobs():
5149
for job in jobs:
5250
# The query already checks that the processing_finished time is null, so here we are saying
5351
# if it started more than 4 hours ago, that's too long
52+
acceptable_finish_time = None
5453
try:
5554
if job.processing_started is not None:
5655
acceptable_finish_time = job.processing_started + timedelta(minutes=5)
@@ -59,7 +58,7 @@ def cleanup_unfinished_jobs():
5958
f"Job ID {job.id} processing_started is {job.processing_started}.",
6059
)
6160
raise
62-
if now > acceptable_finish_time:
61+
if acceptable_finish_time and now > acceptable_finish_time:
6362
remove_csv_object(job.original_file_name)
6463
dao_archive_job(job)
6564

@@ -74,14 +73,12 @@ def delete_notifications_older_than_retention():
7473
)
7574

7675

77-
@notify_celery.task(name="delete-sms-notifications")
78-
@cronitor("delete-sms-notifications")
76+
@notify_celery.task(name="delete-sms-notifications-older-than-retention")
7977
def delete_sms_notifications_older_than_retention():
8078
_delete_notifications_older_than_retention_by_type(NotificationType.SMS)
8179

8280

83-
@notify_celery.task(name="delete-email-notifications")
84-
@cronitor("delete-email-notifications")
81+
@notify_celery.task(name="delete-email-notifications-older-than-retention")
8582
def delete_email_notifications_older_than_retention():
8683
_delete_notifications_older_than_retention_by_type(NotificationType.EMAIL)
8784

@@ -161,7 +158,6 @@ def delete_notifications_for_service_and_type(
161158

162159

163160
@notify_celery.task(name="timeout-sending-notifications")
164-
@cronitor("timeout-sending-notifications")
165161
def timeout_notifications():
166162
notifications = ["dummy value so len() > 0"]
167163

@@ -183,7 +179,6 @@ def timeout_notifications():
183179

184180

185181
@notify_celery.task(name="delete-inbound-sms")
186-
@cronitor("delete-inbound-sms")
187182
def delete_inbound_sms():
188183
try:
189184
start = utc_now()
@@ -199,7 +194,6 @@ def delete_inbound_sms():
199194

200195

201196
@notify_celery.task(name="save-daily-notification-processing-time")
202-
@cronitor("save-daily-notification-processing-time")
203197
def save_daily_notification_processing_time(local_date=None):
204198
# local_date is a string in the format of "YYYY-MM-DD"
205199
if local_date is None:

app/celery/reporting_tasks.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from app import notify_celery
66
from app.config import QueueNames
7-
from app.cronitor import cronitor
87
from app.dao.fact_billing_dao import fetch_billing_data_for_day, update_fact_billing
98
from app.dao.fact_notification_status_dao import update_fact_notification_status
109
from app.dao.notifications_dao import get_service_ids_with_notifications_on_date
@@ -13,7 +12,6 @@
1312

1413

1514
@notify_celery.task(name="create-nightly-billing")
16-
@cronitor("create-nightly-billing")
1715
def create_nightly_billing(day_start=None):
1816
# day_start is a datetime.date() object. e.g.
1917
# up to 4 days of data counting back from day_start is consolidated
@@ -58,7 +56,6 @@ def create_nightly_billing_for_day(process_day):
5856

5957

6058
@notify_celery.task(name="create-nightly-notification-status")
61-
@cronitor("create-nightly-notification-status")
6259
def create_nightly_notification_status():
6360
"""
6461
Aggregate notification statuses into rows in ft_notification_status.

app/celery/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def process_row(row, template, job, service, sender_id=None):
167167
# Assuming the limit is annual, is it calendar year, fiscal year, MOU year?
168168
# Do we need a command to run to clear the redis value, or should it happen automatically?
169169
def __total_sending_limits_for_job_exceeded(service, job, job_id):
170-
print(hilite("ENTER __total_sending_limits_for_job_exceeded"))
170+
171171
try:
172172
total_sent = check_service_over_total_message_limit(KeyType.NORMAL, service)
173173
if total_sent + job.notification_count > service.total_message_limit:

app/clients/pinpoint/aws_pinpoint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def validate_phone_number(self, country_code, phone_number):
3737
# TODO right now this will only print with AWS simulated numbers,
3838
# but remove this when that changes
3939
current_app.logger.info(hilite(response))
40+
return response
4041
except ClientError:
4142
current_app.logger.exception(
4243
"#notify-debug-validate-phone-number Could not validate with pinpoint"

app/commands.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,13 @@ def create_admin_jwt():
752752
@notify_command(name="create-user-jwt")
753753
@click.option("-t", "--token", required=True, prompt=False)
754754
def create_user_jwt(token):
755-
if getenv("NOTIFY_ENVIRONMENT", "") != "development":
755+
if getenv("NOTIFY_ENVIRONMENT", "") not in ["development", "test"]:
756756
current_app.logger.error("Can only be run in development")
757757
return
758758
service_id = token[-73:-37]
759759
api_key = token[-36:]
760-
current_app.logger.info(create_jwt_token(api_key, service_id))
760+
token = create_jwt_token(api_key, service_id)
761+
current_app.logger.info(token)
761762

762763

763764
def _update_template(id, name, template_type, content, subject):

0 commit comments

Comments
 (0)