Skip to content

Commit 1730664

Browse files
Ryan Williamsclaude
andcommitted
daily: wire cells refresh (raw h3 → pyramid → cells.db → D1)
Adds the cells chain to `daily.yml` before the D1 import, and registers `cells` in `api/d1-import.dvc` (cmd + `cells.db` dep). DVX-gated: the heavy pyramid rebuild only runs on days the crash data changed; `d1-import` then exact-diffs cells.db into D1 (~tens of writes/day). `d1-diff.py` now logs the per-table delta so the first runs confirm that volume. The R2 pyramid push for the filtered/parquet path (4b) is deferred — the daily job has no R2 creds yet; the D1 default-view path (4a) needs none. Not yet exercised in CI — must be validated via a scoped `workflow_dispatch` run before the cron relies on it (a cells-stage failure would otherwise block the site deploy). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 37532e2 commit 1730664

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

.github/workflows/daily.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,23 @@ jobs:
154154
- name: Post to Slack
155155
if: ${{ !inputs.targets }}
156156
run: $DVX njsp/data/slack_post.dvc
157+
# Cells refresh for the map. DVX-gated: the pyramid rebuild only runs on
158+
# days the crash data actually changed. `cells.db` (the D1 rollup source)
159+
# feeds the d1-import below; the R2 pyramid push for the filtered/parquet
160+
# path is deferred (needs R2 creds — see 4b).
161+
- name: Rebuild cells raw H3 index
162+
if: ${{ !inputs.targets }}
163+
run: $DVX data/cells/raw/h3_r15.dvc
164+
- name: Rebuild cells pyramid
165+
if: ${{ !inputs.targets }}
166+
run: $DVX data/cells/pyramid.dvc
167+
- name: Rebuild cells rollup DB (D1 source)
168+
if: ${{ !inputs.targets }}
169+
run: $DVX data/cells/cells.db.dvc
157170
- name: Install api dependencies
158171
if: ${{ !inputs.targets }}
159172
run: cd api && pnpm install
160-
- name: Sync NJSP crashes.db → D1
173+
- name: Sync crash DBs (NJSP, cmymc, cells) → D1
161174
if: ${{ !inputs.targets }}
162175
run: $DVX api/d1-import.dvc
163176
- name: Regenerate homepage OG mosaic (→ S3)

api/d1-import.dvc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
meta:
22
computation:
3-
cmd: bash scripts/d1-import.sh --inplace njsp-crashes cmymc
3+
cmd: bash scripts/d1-import.sh --inplace njsp-crashes cmymc cells
44
deps:
55
/www/public/njsp/crashes.db: 6ade2d0f110f6012132763f54b8f2a0e
66
/www/public/njdot/cmymc.db: 9a59b8fefd7f0559c935d147c4622572
7+
/data/cells/cells.db: a8d179291a9528aaa5924304341fca28
78
git_deps:
8-
scripts/d1-import.sh: 80bbb27c725d2f243dcb79d6f52406f378301d1b
9+
scripts/d1-import.sh: 0020fb0125c04a7fd7f9c6573893e2cd1721ceb5

api/scripts/d1-diff.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ def main():
7070

7171
conn.close()
7272

73+
# One-line delta summary → stderr, so the import log shows the actual
74+
# daily write volume per table (expected ~tens for the cells rollup).
75+
print(f" d1-diff {table}: {len(delete_pks)} delete + {len(upsert_rows)} upsert row(s)", file=sys.stderr)
76+
7377
out_del = Path(args.out_delete)
7478
out_ins = Path(args.out_upsert)
7579
out_del.parent.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)