Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an operational backfill path for GTFS dataset changelog records by introducing a new tasks_executor task that enumerates missing consecutive dataset pairs and dispatches rate-limited Cloud Tasks to the existing gtfs-datasets-comparer function, while aligning DB schema/API vocabulary from (previous, current) to (base, new).
Changes:
- Introduces
backfill_changelogtask + unit tests to enumerate/dispatch missing changelog pairs with idempotency controls (dry_run,force, filters, limits). - Renames
gtfs_dataset_changelogcolumns/constraints/indexes to(base_dataset_id, new_dataset_id)via Liquibase and updates call sites accordingly. - Adds a dedicated Cloud Tasks queue for backfill dispatches and wires it into the
tasks_executorfunction environment.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| liquibase/changes/feat_1639.sql | Renames changelog table columns + associated constraints/index to base/new vocabulary. |
| liquibase/changelog.xml | Registers the new Liquibase migration in the changelog sequence. |
| infra/functions-python/main.tf | Adds a backfill-specific Cloud Tasks queue and injects it into tasks_executor env vars. |
| functions-python/tasks_executor/src/tasks/changelog/backfill_changelog.py | Implements the backfill enumeration, idempotency checks, filtering, and task dispatch. |
| functions-python/tasks_executor/tests/tasks/changelog/test_backfill_changelog.py | Adds unit tests covering dry-run, dispatch, force, filtering, and edge cases. |
| functions-python/tasks_executor/src/main.py | Registers the new backfill_changelog task in the tasks map. |
| functions-python/tasks_executor/README.md | Documents the new task, parameters, env vars, and response fields. |
| functions-python/helpers/utils.py | Extends comparer Cloud Task helper to support disallow_overwrite flag. |
| functions-python/gtfs_datasets_comparer/src/main.py | Renames internal variables and DB upsert fields to base/new; updates conflict constraint name. |
| functions-python/gtfs_datasets_comparer/tests/test_main.py | Updates tests to match base/new naming and error messages. |
| functions-python/batch_process_dataset/src/pipeline_tasks.py | Updates changelog existence check to use base/new columns. |
| api/src/shared/database/database.py | Updates mapper cascade relationship comments to reflect base/new terminology. |
davidgamez
reviewed
Jun 23, 2026
| -- Rename gtfs_dataset_changelog dataset columns from (previous, current) to (base, new) | ||
| -- so the database matches the comparer HTTP API naming (base_dataset_stable_id / | ||
| -- new_dataset_stable_id) and a single, consistent vocabulary is used everywhere | ||
| ALTER TABLE gtfs_dataset_changelog RENAME COLUMN previous_dataset_id TO base_dataset_id; |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
backfill_changelogtask totasks_executorthat walks existing dataset history and dispatches Cloud Tasks to thegtfs-datasets-comparerfor each consecutive(base, new)dataset pair missing a changelog recordgtfs_dataset_changelogcolumns from(previous_dataset_id, current_dataset_id)to(base_dataset_id, new_dataset_id)via a Liquibase migration, aligning the DB schema with the comparer HTTP API naminggtfs-datasets-comparer-backfill-queue) with rate limiting (1 req/s, 10 concurrent) and retry config for backfill dispatchesKey design decisions
force=True), and dispatched tasks run withdisallow_overwrite=Trueby defaultlimitcaps feeds per invocation,datasets_per_feedcontrols how deep into history we look (default: 3 most recent → 2 pairs), and the Cloud Tasks queue throttles comparer invocationsstable_feed_idsto target specific feeds andfeeds_not_updated_daysto focus on stale feedsdry_run=Trueenumerates pairs without dispatching, making it safe to preview before runningNote about testing
Only 25 feeds in DEV have enough comparable datasets (with extracted files) to produce changelog pairs. Backfill ran successfully against all of them with no issues found.
Further testing in QA is impractical for this feature: QA mirrors the production database but does not have access to the production GCS bucket where extracted GTFS files are stored. Since the comparer reads those files to compute diffs, changelog generation fails without them. Meaningful end-to-end validation will need to happen in PROD (starting with a scoped dry-run, then a small
stable_feed_idsbatch).Please make sure these boxes are checked before submitting your pull request - thanks!
./scripts/api-tests.shto make sure you didn't break anything