-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe1a874
commit 883614d
Showing
12 changed files
with
216 additions
and
149 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["ms-python.black-formatter", "ms-python.flake8"] | ||
} |
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,8 @@ | ||
{ | ||
"python.formatting.blackPath": ".venv/bin/black", | ||
"python.formatting.provider": "black", | ||
"editor.formatOnSave": true, | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,13 @@ | ||
# 🏮 MBTA Performance Processing (LAMPLighter) | ||
|
||
Scripts for processing MBTA performance data both from LAMP and from monthly historical files | ||
Scripts for processing MBTA performance data both from LAMP and from monthly historical files | ||
|
||
## Requirements to develop locally | ||
|
||
- Python 3.12 with recent poetry (1.7.0 or later) | ||
- Verify with `python --version && poetry --version` | ||
- `poetry self update` to update poetry | ||
|
||
## Instructions to run locally | ||
|
||
1. Add your AWS credentials (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) to your shell environment, OR add them to a .boto config file with awscli command `aws configure`. |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
__all__ = ["ingest_lamp_data"] | ||
__all__ = ["ingest_today_lamp_data"] | ||
|
||
from .ingest import ingest_lamp_data | ||
from .ingest import ingest_today_lamp_data |
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,31 @@ | ||
import pandas as pd | ||
from ..ingest import LAMP_INDEX_URL, fetch_pq_file_from_remote, ingest_pq_file, upload_to_s3 | ||
from ... import parallel | ||
|
||
|
||
_parallel_upload = parallel.make_parallel(upload_to_s3) | ||
|
||
|
||
def backfill_all_in_index(): | ||
"""Backfill all the dates in the LAMP index.""" | ||
|
||
# Load the index | ||
index = pd.read_csv(LAMP_INDEX_URL) | ||
# Get the dates in the index | ||
dates = pd.to_datetime(index["service_date"]).dt.date | ||
# Backfill each date | ||
for date_to_backfill in dates: | ||
try: | ||
pq_df = fetch_pq_file_from_remote(date_to_backfill) | ||
except ValueError as e: | ||
# If we can't fetch the file, we can't process it | ||
print(f"Failed to fetch {date_to_backfill}: {e}") | ||
processed_daily_events = ingest_pq_file(pq_df) | ||
|
||
# split daily events by stop_id and parallel upload to s3 | ||
stop_event_groups = processed_daily_events.groupby("stop_id") | ||
_parallel_upload(stop_event_groups, date_to_backfill) | ||
|
||
|
||
if __name__ == "__main__": | ||
backfill_all_in_index() |
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
2 changes: 1 addition & 1 deletion
2
...rmance/chalicelib/lamp/tests/test_util.py → ...rmance/chalicelib/lamp/tests/test_date.py
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.