Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements enhancements to batch dataset processing to address memory issues and improve reliability. It introduces targeted feed processing, refactors dataset handling into cleaner separation of concerns, and increases resource allocation to handle large file downloads more effectively.
Key changes:
- Added support for limiting feeds to process via optional
feed_stable_idsparameter in batch datasets function - Split dataset processing into two distinct methods:
process_from_producer_urlfor direct downloads andprocess_from_bucket_latestfor rebuilding from GCS - Increased function memory allocation from 2Gi to 8Gi and CPU from 1 to 2 cores with 7Gi in-memory storage limit
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| infra/functions-python/main.tf | Updated environment variables for Pub/Sub topic names |
| functions-python/batch_process_dataset/function_config.json | Increased memory and CPU allocation for better performance |
| functions-python/batch_process_dataset/src/main.py | Added new processing method and refactored file upload logic |
| functions-python/batch_datasets/src/main.py | Added optional feed filtering capability |
| functions-python/tasks_executor/src/tasks/dataset_files/rebuild_missing_dataset_files.py | Refactored to use Pub/Sub messages instead of direct processing |
| functions-python/helpers/utils.py | Added GCS download utility function |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
davidgamez
approved these changes
Aug 18, 2025
Comment on lines
+93
to
97
| if feed_stable_ids: | ||
| # If feed_stable_ids are provided, filter the query by stable IDs | ||
| query = query.filter(Gtfsfeed.stable_id.in_(feed_stable_ids)) | ||
| # Limit the query to 10 feeds (or FEEDS_LIMIT param) for testing purposes and lower environments | ||
| if os.getenv("ENVIRONMENT", "").lower() in ("dev", "test", "qa"): |
Member
There was a problem hiding this comment.
nitpick: I would have the limit no applied when the feed_stable_ids are passed.
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
Closes #1297
This PR addresses a bug related to GCP’s handling of function memory and local storage, where large file downloads consume function memory. To mitigate this, we’ve introduced an explicit in-memory storage limit and increased allocated resources to ensure more reliable and predictable behavior.
Important
This change requires manual setup across envs, as the configuration is not currently supported by Terraform or the Google API.
Key Changes
Batch Datasets Function Enhancements
feed_stable_idslist in the request body, enabling targeted processing of specific feeds.Dataset Processing Refactor
Split dataset processing into two clearer methods:
process_from_producer_url: downloads directly from producer URLs.process_from_bucket_latest: rebuilds datasets from the latest version in GCS.This improves code clarity, maintainability, and separation of responsibilities.
Resource Allocation Updates
File System Adjustments
/in-memoryinstead of/tmpto better align with GCP function storage semantics.Please make sure these boxes are checked before submitting your pull request - thanks!
./scripts/api-tests.shto make sure you didn't break anything