-
Notifications
You must be signed in to change notification settings - Fork 6
feat: added batch fill for dataset size and files #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f31c789
added batch fill for dataset size and files
cka-y 3d09173
updated readme
cka-y 38cc37d
tests
cka-y b56a193
Merge branch 'main' into feat/1260
cka-y f1f331f
updated process dataset function
cka-y c671e8c
pr comments
cka-y f83037c
adding secret to task executor
cka-y cb7a075
adding secret to task executor
cka-y 038c89c
modifies secret manager
cka-y 2c2e625
fix: unique secret dicts in tf
cka-y 7070698
fix: unique_secret_dict_map
cka-y 9ecc333
merge main
cka-y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,10 @@ | |
| "secret_environment_variables": [ | ||
| { | ||
| "key": "FEEDS_DATABASE_URL" | ||
| }, | ||
| { | ||
| "key": "FEEDS_CREDENTIALS", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💪 |
||
| "secret": "FEEDS_CREDENTIALS" | ||
| } | ||
| ], | ||
| "ingress_settings": "ALLOW_ALL", | ||
|
|
||
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
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
72 changes: 72 additions & 0 deletions
72
functions-python/tasks_executor/src/tasks/dataset_files/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Rebuild Missing Dataset Files | ||
|
|
||
| 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. | ||
|
|
||
| --- | ||
|
|
||
| ## Task ID | ||
|
|
||
| Use task ID: `rebuild_missing_dataset_files` | ||
|
|
||
| --- | ||
|
|
||
| ## Usage | ||
|
|
||
| The function accepts the following payload: | ||
|
|
||
| ```json | ||
| { | ||
| "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) | ||
|
cka-y marked this conversation as resolved.
|
||
| } | ||
| ``` | ||
|
|
||
| ### Example: | ||
|
|
||
| ```json | ||
| { | ||
| "dry_run": false, | ||
| "after_date": "2025-07-01", | ||
| "latest_only": true | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## What It Does | ||
|
|
||
| For each GTFS dataset with missing file information (missing zipped/unzipped sizes or missing extracted files), this function: | ||
|
|
||
| 1. Downloads the `.zip` file from its `hosted_url` | ||
| 2. Computes the zipped size in bytes | ||
| 3. Extracts all GTFS files locally | ||
| 4. Computes the unzipped size in bytes | ||
| 5. Uploads each extracted file to a GCS bucket with the structure: | ||
|
|
||
| ``` | ||
| {feed-stable-id}/{dataset-stable-id}/extracted/{file_name} | ||
| ``` | ||
| 6. Makes each file publicly accessible and stores its GCS URL | ||
| 7. Computes SHA256 hashes for each file | ||
| 8. Stores metadata in the `Gtfsfile` table for later use | ||
|
|
||
| --- | ||
|
|
||
| ## GCP Environment Variables | ||
|
|
||
| The function requires the following environment variables: | ||
|
|
||
| | Variable | Description | | ||
| | ---------------------- | ---------------------------------------------------------------------------- | | ||
| | `DATASETS_BUCKET_NAME` | The name of the GCS bucket used to store extracted GTFS files | | ||
|
|
||
| --- | ||
|
|
||
| ## Additional Notes | ||
|
|
||
| * 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_run` is 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. | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.