-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add alert delays to daily runs #113
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
04e64d6
Add alert delays to daily runs
devinmatte 675f6ee
Look back 8 days
devinmatte 7ff1e5f
Only run on Mondays
devinmatte d896e18
Make sure weekly runs happen
devinmatte d4cd701
Slightly reduce runs
devinmatte 61b2e16
Updating lock
devinmatte 140de21
Update dependencies
devinmatte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "arn:*:logs:*:*:*" | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": ["dynamodb:BatchWriteItem"], | ||
"Resource": [ | ||
"arn:aws:dynamodb:us-east-1:473352343756:table/AlertDelaysWeekly" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
agg_speed_tables, | ||
gtfs, | ||
ridership, | ||
delays, | ||
speed_restrictions, | ||
predictions, | ||
landing, | ||
|
@@ -94,8 +95,8 @@ def update_ridership(event): | |
ridership.ingest_ridership_data() | ||
|
||
|
||
# 7:20am UTC -> 2:20/3:20am ET every day | ||
@app.schedule(Cron(20, 7, "*", "*", "?", "*")) | ||
# 7:20am UTC -> 2:20/3:20am ET every weekday | ||
@app.schedule(Cron(20, 7, "?", "*", "MON-FRI", "*")) | ||
def update_speed_restrictions(event): | ||
speed_restrictions.update_speed_restrictions(max_lookback_months=2) | ||
|
||
|
@@ -106,6 +107,15 @@ def update_time_predictions(event): | |
predictions.update_predictions() | ||
|
||
|
||
# 7:45am UTC -> 2:45/3:45am ET every Monday | ||
# There's no benefit to running it more frequently than once a week. | ||
@app.schedule(Cron(45, 7, "?", "*", "MON", "*")) | ||
def update_alert_delays(event): | ||
today = datetime.now() | ||
one_week_ago = (today - timedelta(days=8)).date() | ||
delays.update_table(one_week_ago, today.date()) | ||
|
||
|
||
# 8:00am UTC -> 3:00/4:00am ET every day | ||
@app.schedule(Cron(0, 8, "*", "*", "?", "*")) | ||
def update_gtfs(event): | ||
|
@@ -138,8 +148,10 @@ def populate_agg_delivered_trip_metrics(params, context): | |
agg_speed_tables.populate_table(line, "weekly") | ||
|
||
|
||
# 9:00 UTC -> 4:00/5:00am ET every day. | ||
@app.schedule(Cron(0, 9, "*", "*", "?", "*")) | ||
# 9:00 UTC -> 4:00/5:00am ET every weekday. | ||
# This is the last job that runs for the day. | ||
# No need to run on weekends | ||
@app.schedule(Cron(0, 9, "?", "*", "MON-FRI", "*")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reducing runs to reduce AWS cost slightly since it shouldn't serve any benefit |
||
def store_landing_data(event): | ||
print( | ||
f"Uploading ridership and trip metric data for landing page from {constants.NINETY_DAYS_AGO_STRING} to {constants.ONE_WEEK_AGO_STRING}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__all__ = ["update_table"] | ||
|
||
from .process import update_table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reducing runs to reduce AWS cost slightly since it shouldn't serve any benefit