Skip to content

Commit 061a40a

Browse files
committed
secrets fixed! fn git
1 parent 1990c06 commit 061a40a

File tree

7 files changed

+78
-4
lines changed

7 files changed

+78
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Deploy to Cloud Run Job
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: google-github-actions/auth@v2
15+
with:
16+
credentials_json: ${{ secrets.GCP_SA_KEY }}
17+
18+
- uses: google-github-actions/setup-gcloud@v2
19+
20+
- name: Configure Docker
21+
run: gcloud auth configure-docker us-central1-docker.pkg.dev
22+
23+
- name: Build & Push Image
24+
run: |
25+
IMAGE=us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/fec/fec:latest
26+
docker build -t $IMAGE .
27+
docker push $IMAGE
28+
29+
- name: Update Cloud Run Job
30+
run: |
31+
gcloud run jobs update fec-ingest \
32+
--image $IMAGE \
33+
--region ${{ secrets.GCP_REGION }}

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /app
4+
5+
COPY requirements.txt* ./
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY app/ app/
9+
10+
CMD ["python", "-m", "app.main"]

app/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77

88
FEC_URL = "https://api.open.fec.gov/v1/schedules/{}"
99

10+
CYCLE = 2026
11+
1012
DATA_DIR = Path(os.getenv("DATA_DIR", "data"))
1113

1214
POSTGRES_URL = os.getenv(
1315
"POSTGRES_URL",
1416
"postgresql+psycopg2://localhost/postgres",
1517
)
1618

19+
DT_FORMAT = "%Y-%m-%d"
20+
1721

1822
@dataclass(frozen=True)
1923
class VariantSpec:

app/helpers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Dict, Any, List
44
import json
55
from app.logger import logger
6+
from app.config import DT_FORMAT
67
from pathlib import Path
78
from datetime import datetime as dt
89
from typing import Optional
@@ -43,6 +44,12 @@ def get_now():
4344
ts = now_hour.strftime("%Y-%m-%d %H:00")
4445
return ts
4546

47+
48+
def get_today():
49+
now_ = dt.now(ZoneInfo("America/New_York"))
50+
ts = now_.strftime(DT_FORMAT)
51+
return ts
52+
4653
# ------------------------------------------------------------------------------
4754
# retry helpers
4855
# ------------------------------------------------------------------------------

app/main.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from app.query import fetch, FetchRun
22
from app.ingestion import ingest_jsonl
33
from app.mail import send_email
4-
from app.db import get_engine
5-
from app.helpers import get_now, format_results
4+
from app.db import get_engine, create_tables
5+
from app.helpers import get_now, format_results, get_today
6+
from app.config import CYCLE
67
import os
78
import time
89

@@ -47,7 +48,17 @@ def run(variant, key, cycle):
4748
send_email(
4849
subject=subject,
4950
body=body,
50-
to=os.getenv('TEST_TARGETS'),
51+
to="afriedman412@gmail.com",
5152
sender="steadynappin@gmail.com",
5253
df=new_data_df
5354
)
55+
56+
57+
if __name__ == "__main__":
58+
today = get_today()
59+
create_tables()
60+
run(
61+
variant="expenditure",
62+
key=today,
63+
cycle=CYCLE
64+
)

app/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class FetchRun:
4343
def __init__(
4444
self,
4545
*,
46-
variant: Literal["date", "committee"],
46+
variant: Literal["expenditure", "contribution"],
4747
key: str,
4848
cycle: int,
4949
per_page: int = 100,

requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,41 @@ decorator==5.2.1
99
executing==2.2.1
1010
greenlet==3.3.0
1111
idna==3.11
12+
iniconfig==2.3.0
1213
ipykernel==7.1.0
1314
ipython==9.8.0
1415
ipython_pygments_lexers==1.1.1
1516
jedi==0.19.2
1617
jupyter_client==8.7.0
1718
jupyter_core==5.9.1
1819
matplotlib-inline==0.2.1
20+
mirakuru==3.0.1
1921
nest-asyncio==1.6.0
2022
numpy==2.3.5
2123
packaging==25.0
2224
pandas==2.3.3
2325
parso==0.8.5
2426
pexpect==4.9.0
2527
platformdirs==4.5.1
28+
pluggy==1.6.0
29+
port-for==1.0.0
2630
prompt_toolkit==3.0.52
2731
psutil==7.1.3
32+
psycopg==3.3.2
2833
psycopg2-binary==2.9.11
2934
ptyprocess==0.7.0
3035
pure_eval==0.2.3
3136
pydantic==2.12.5
3237
pydantic_core==2.41.5
3338
Pygments==2.19.2
39+
pytest==9.0.2
40+
pytest-env==1.2.0
3441
python-dateutil==2.9.0.post0
42+
python-dotenv==1.2.1
3543
pytz==2025.2
3644
pyzmq==27.1.0
3745
requests==2.32.5
46+
secure-smtplib==0.1.1
3847
six==1.17.0
3948
SQLAlchemy==2.0.45
4049
sqlmodel==0.0.27

0 commit comments

Comments
 (0)