This task rebuilds missing extracted files in GTFS datasets.
It downloads datasets from their hosted_url, extracts all files, computes zipped and unzipped sizes, calculates hashes, uploads the files to a GCS bucket, and updates the database.
Use task ID: rebuild_missing_dataset_files
The function accepts the following payload:
{
"dry_run": true, // [optional] If true, do not upload or modify the database (default: true)
"after_date": "YYYY-MM-DD", // [optional] Only include datasets downloaded after this ISO date
"latest_only": true // [optional] If true, only process the latest version of each dataset (default: true)
}{
"dry_run": false,
"after_date": "2025-07-01",
"latest_only": true
}For each GTFS dataset with missing file information (missing zipped/unzipped sizes or missing extracted files), this function:
-
Downloads the
.zipfile from itshosted_url -
Computes the zipped size in bytes
-
Extracts all GTFS files locally
-
Computes the unzipped size in bytes
-
Uploads each extracted file to a GCS bucket with the structure:
{feed-stable-id}/{dataset-stable-id}/extracted/{file_name} -
Makes each file publicly accessible and stores its GCS URL
-
Computes SHA256 hashes for each file
-
Stores metadata in the
Gtfsfiletable for later use
The function requires the following environment variables:
| Variable | Description |
|---|---|
DATASETS_BUCKET_NAME |
The name of the GCS bucket used to store extracted GTFS files |
- This function disables SSL verification when downloading files, as the sources are trusted internally.
- Commits to the database occur in batches of 5 datasets to improve performance and avoid large transaction blocks.
- If
dry_runis enabled, no downloads, uploads, or DB modifications are performed. Only the number of affected datasets is logged. - The function is safe to rerun. It will only affect datasets missing required file metadata.