Skip to content

Commit a755a95

Browse files
authored
Upgrading the repo to python 3.12 (#132)
1 parent 5e988b8 commit a755a95

12 files changed

Lines changed: 537 additions & 463 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11"]
14+
python-version: ["3.12"]
1515
env:
1616
AWS_PROFILE: transitmatters
1717
AWS_DEFAULT_REGION: us-east-1

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11"]
14+
python-version: ["3.12"]
1515
steps:
1616
- name: Checkout repo
1717
uses: actions/checkout@v4

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11"]
14+
python-version: ["3.12"]
1515
steps:
1616
- name: Checkout repo
1717
uses: actions/checkout@v4

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 TransitMatters
3+
Copyright (c) 2025 TransitMatters
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# data-ingestion
2+
23
![lint](https://github.com/transitmatters/data-ingestion/workflows/lint/badge.svg?branch=main)
34
![test](https://github.com/transitmatters/data-ingestion/workflows/test/badge.svg?branch=main)
45
![deploy](https://github.com/transitmatters/data-ingestion/workflows/deploy/badge.svg?branch=main)

devops/deploy.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,28 @@ pushd ingestor/
2525
poetry run chalice package --stage prod --merge-template .chalice/resources.json cfn/
2626

2727
# Shrink the deployment package for the lambda layer https://stackoverflow.com/a/69355796
28-
echo "Shrinking the deployment package for the lambda layer"
28+
actualsize=$(wc -c <"cfn/layer-deployment.zip")
29+
echo "Shrinking the deployment package for the lambda layer. It's currently $actualsize bytes."
2930

3031
source ../devops/helpers.sh
31-
shrink
32+
shrink > /dev/null 2>&1
33+
34+
# Check the size of the new package
35+
newsize=$(wc -c <"cfn/layer-deployment.zip")
36+
echo "The deployment package is now $newsize bytes"
37+
diffsize=$(($actualsize - $newsize))
38+
echo "Difference: $diffsize bytes"
3239

3340
# Check package size before deploying
3441
maximumsize=79100000
3542
actualsize=$(wc -c <"cfn/layer-deployment.zip")
43+
difference=$(expr $actualsize - $maximumsize)
3644
if [ $actualsize -ge $maximumsize ]; then
3745
echo ""
38-
echo "layer-deployment.zip is over $maximumsize bytes. Shrink the package further to be able to deploy"
46+
echo "layer-deployment.zip is over $maximumsize bytes. Shrink the package by $difference bytes to be able to deploy"
3947
exit 1
4048
fi
49+
echo "layer-deployment.zip is under the maximum size of $maximumsize bytes, by $difference bytes"
4150

4251
aws cloudformation package --template-file cfn/sam.json --s3-bucket $BUCKET --output-template-file cfn/packaged.yaml
4352
aws cloudformation deploy --template-file cfn/packaged.yaml --stack-name $STACK_NAME \

devops/helpers.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,23 @@ function shrink {
77
zip -d -qq cfn/layer-deployment.zip '**/LICENSE*'
88
zip -d -qq cfn/layer-deployment.zip '**/AUTHOR*'
99
zip -d -qq cfn/layer-deployment.zip '**/NOTICE*'
10+
zip -d -qq cfn/layer-deployment.zip '**/*.md'
11+
zip -d -qq cfn/layer-deployment.zip '**/*.c'
12+
zip -d -qq cfn/layer-deployment.zip '**/*.cpp'
13+
zip -d -qq cfn/layer-deployment.zip '**/*.h'
14+
zip -d -qq cfn/layer-deployment.zip '**/*.pyx'
15+
zip -d -qq cfn/layer-deployment.zip '**/*.pxd'
1016
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/numpy*/tests/**/*
1117
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/pandas*/tests/**/*
18+
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/pandas/tests/**/*
19+
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/pandas/_libs/tslibs/src/datetime/*
20+
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/pandas/io/formats/templates/*
1221
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/boto*/examples/*
22+
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/sqlalchemy*/testing/**/*
23+
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/sqlalchemy/dialects/oracle/**/*
24+
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/sqlalchemy/dialects/mssql/**/*
25+
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/sqlalchemy/dialects/mysql/**/*
26+
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/sqlalchemy/dialects/postgresql/**/*
1327
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/*/zoneinfo/Africa/*
1428
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/*/zoneinfo/Asia/*
1529
zip -d -qq cfn/layer-deployment.zip python/lib/**/site-packages/*/zoneinfo/Atlantic/*

ingestor/.chalice/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"app_name": "ingestor",
44
"automatic_layer": true,
55
"layers": [
6-
"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension:76"
6+
"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension:78"
77
],
88
"stages": {
99
"prod": {
@@ -124,4 +124,4 @@
124124
}
125125
}
126126
}
127-
}
127+
}

ingestor/chalicelib/parallel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ def month_range(start, end):
3131
# So we generate a daily date_range and then resample it down (summing 0s as a no-op in the process) so it aligns.
3232
dates = pd.date_range(start, end, freq="1D", inclusive="both")
3333
series = pd.Series(0, index=dates)
34-
months = series.resample("1M").sum().index
34+
months = series.resample("ME").sum().index
3535
return months

ingestor/chalicelib/ridership/process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def format_ridership_csv(
5151
holidays = cal.holidays(start=df[date_key].min(), end=df[date_key].max())
5252

5353
# mark as holiday and weekday
54-
df["holiday"] = df[date_key].dt.date.astype("datetime64").isin(holidays.date)
54+
df["holiday"] = df[date_key].dt.date.astype("datetime64[ns]").isin(holidays.date)
5555
df["weekday"] = df[date_key].dt.dayofweek
5656

5757
# define peak, mark weekdays, convert service date back
@@ -99,7 +99,7 @@ def format_subway_data(path_to_csv_file: str):
9999
holidays = cal.holidays(start=df["servicedate"].min(), end=df["servicedate"].max())
100100

101101
# mark as holiday and weekday
102-
df["holiday"] = df["servicedate"].dt.date.astype("datetime64").isin(holidays.date)
102+
df["holiday"] = df["servicedate"].dt.date.astype("datetime64[ns]").isin(holidays.date)
103103
df["weekday"] = df["servicedate"].dt.dayofweek
104104

105105
# define peak, mark weekdays, convert service date back

0 commit comments

Comments
 (0)