Repository navigation
Build stations.db with meteo CLI and split inventory sync - #519
Conversation
- sync-database: build stations.db via `meteo station build` on station changes, keep the existing inventory table, upload and commit - sync-inventory: weekly refresh of the inventory table only - Upload to a temp file and rename on the FTP server so readers never see a partial file - Remove database.py and tables.sql Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It reworks a production deployment pipeline that depends on unverifiable external pieces (the meteo station build CLI, FTP rename-onto-existing-file behavior, and a server-side PHP import webhook) that the author explicitly flags as untested.
Review effort: Balanced
Findings: None
What changed in this PR
This PR reworks how the published stations.db is produced and synced, replacing the previous sqlite3mysql-based MySQL export (from #518) with a simpler, split-workflow approach. Building the database from stations/*.json and refreshing the Meteostat inventory table are now decoupled into two workflows, and the actual MySQL import is delegated to a server-side PHP webhook outside this repo. The legacy JSON→SQLite conversion script and its SQL schema are removed in favor of the meteo station build CLI.
Changes:
- Rebuilt
sync-database.ymlto buildstations.dbviameteo station build, copy the existinginventorytable into the fresh file, upload atomically over FTP (temp file + rename), commit/push, and trigger a server-side import webhook; trigger changed from a daily cron to pushes onstations/*.json. - Added
sync-inventory.yml(weekly) that replaces only theinventorytable viamysql2sqliteand uploads the same way; both workflows share onestations-dbconcurrency group. - Removed
database.py,tables.sql, andrequirements.txt(local SQLite build artifacts no longer needed).
| File | Description |
|---|---|
.github/workflows/sync-database.yml |
Builds DB with meteo CLI, preserves inventory, atomic FTP upload, and server import webhook; new push trigger + concurrency group. |
.github/workflows/sync-inventory.yml |
New weekly workflow that refreshes only the inventory table from MySQL and uploads/commits. |
database.py |
Removed legacy JSON→SQLite conversion script (also generated locations.csv.gz). |
tables.sql |
Removed SQL schema used by the deleted database.py. |
requirements.txt |
Removed; dependencies are now installed inline per workflow. |
I verified that no remaining code, workflow, or documentation references the removed database.py, tables.sql, or requirements.txt, that the inventory table is self-contained (no foreign keys) so the .dump inventory → pipe-into-fresh-DB step works, and that the FTP temp-upload-then-rename and shared concurrency group are internally consistent across both workflows. I did not find concrete code-level defects to comment on.
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Summary
This replaces the slow
sqlite3mysqlimport from #518. Buildingstations.dband refreshing the inventory are now separate workflows. Importing into MySQL now happens on the server, with a PHP script (stations-import.php) that is not part of this repo.sync-database.yml(on pushes tostations/*.json, or started manually)stations.dbwithmeteo station build(meteostat-cli[contrib]; Python 3.12).inventorytable from the currentstations.dbinto the new file, since the build creates a fresh file without it.stations.db.tmpand renames it tostations.dbin the same call. Readers on the server never see a partial file.sync-inventory.yml(weekly, Mondays 02:00 UTC, or started manually)inventorytable in the existingstations.db(mysql2sqlite -t inventory), then uploads the same way and commits.Both workflows share one concurrency group, so they never run at the same time or push conflicting commits.
Removed:
database.pyandtables.sql.requirements.txtis back tomysql-to-sqlite3andpandas.Notes
meteo station buildskips stations that fail validation. It currently skips 49, mostly because two stations share an identifier. These stations will be missing fromstations.dband from MySQL after the server import. Fix the data, or add--skip-validation.locations.csv.gzis no longer generated. Onlydatabase.pygenerated it.🤖 Generated with Claude Code