-
Notifications
You must be signed in to change notification settings - Fork 6
feat: reverse geolocation per polygon strategy #1318
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
davidgamez
merged 36 commits into
main
from
feat/reverse_geolocation_per_polygon_strategy
Aug 27, 2025
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
2caf6fa
first stable implementation
davidgamez 3cd15ad
revisit all functions and clean-up code
davidgamez e55899b
fix duplicate reverse geolocation and add gtfs to the verifier
davidgamez 38f6057
Merge branch 'main' into feat/reverse_geolocation_per_polygon_strategy
davidgamez fdf9bd4
Update Feedlocationgrouppoint implementation
davidgamez e019989
Fix location primary key violation
davidgamez 861ee0d
Fix failing tests
davidgamez 94b3649
fix failing test
davidgamez 9fe5ac7
increase reverse_geolocation_processor test coverage
davidgamez 720cf8d
Increase per polygon test coverage
davidgamez 186562b
fix per polygon batch
davidgamez 1b5d27c
fix number of stops per cluster
davidgamez 6862ba4
fix number of stops per cluster
davidgamez 0f2e305
Increase locations helper test coverage
davidgamez dcf64a3
Add additional commit and make sure current stop is processed
davidgamez 2997ce7
Fix task executor function URL
davidgamez 062ebe6
Change the default strategy to per polygon
davidgamez f6c9cc8
Merge branch 'main' into feat/reverse_geolocation_per_polygon_strategy
davidgamez 6e7eedb
Add maximum executions check
davidgamez 492f2d2
Add missing environment variables
davidgamez 3a08423
Fix location group cache saving
davidgamez 0b02ee5
Fix duplicate calls
davidgamez 3b7ff56
Add missing file
davidgamez 139d9ba
Enhance logging
davidgamez badc9fa
Fix duplicate admin levels
davidgamez ffc4905
Fix lint
davidgamez ed05df1
Fix import
davidgamez b41101e
fix tests imports
davidgamez 792ad45
Add create_refresh_materialized_view_task call
davidgamez 40cec16
Fix logging percentage
davidgamez 6c5729a
Add missing refresh view variables
davidgamez 575db17
Add missing refresh view variables
davidgamez 0626178
Improve task creation logs
davidgamez 452ceb0
Fix gcp function parameter name
davidgamez b15eeef
add missing task name in call
davidgamez 1aa0298
Merge branch 'main' into feat/reverse_geolocation_per_polygon_strategy
davidgamez 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
43 changes: 43 additions & 0 deletions
43
functions-python/dataset_service/dataset_service_commons.py
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,43 @@ | ||
| from dataclasses import dataclass | ||
| from datetime import datetime | ||
| from enum import Enum | ||
| from typing import Optional | ||
|
|
||
|
|
||
| # Status of the dataset trace | ||
| class Status(Enum): | ||
| FAILED = "FAILED" | ||
| SUCCESS = "SUCCESS" | ||
| PUBLISHED = "PUBLISHED" | ||
| NOT_PUBLISHED = "NOT_PUBLISHED" | ||
| PROCESSING = "PROCESSING" | ||
|
|
||
|
|
||
| # Stage of the pipeline | ||
| class PipelineStage(Enum): | ||
| DATASET_PROCESSING = "DATASET_PROCESSING" | ||
| LOCATION_EXTRACTION = "LOCATION_EXTRACTION" | ||
| GBFS_VALIDATION = "GBFS_VALIDATION" | ||
|
|
||
|
|
||
| # Dataset trace class to store the trace of a dataset | ||
| @dataclass | ||
| class DatasetTrace: | ||
| stable_id: str | ||
| status: Status | ||
| timestamp: datetime | ||
| dataset_id: Optional[str] = None | ||
| trace_id: Optional[str] = None | ||
| execution_id: Optional[str] = None | ||
| file_sha256_hash: Optional[str] = None | ||
| hosted_url: Optional[str] = None | ||
| pipeline_stage: PipelineStage = PipelineStage.DATASET_PROCESSING | ||
| error_message: Optional[str] = None | ||
|
|
||
|
|
||
| # Batch execution class to store the trace of a batch execution | ||
| @dataclass | ||
| class BatchExecution: | ||
| execution_id: str | ||
| timestamp: datetime | ||
| feeds_total: int |
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
Empty file.
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ omit = | |
| database.py | ||
| */database_gen/* | ||
| */dataset_service/* | ||
| */shared/common/* | ||
|
|
||
| [report] | ||
| exclude_lines = | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -17,8 +17,6 @@ | |
| import logging | ||
| import threading | ||
|
|
||
| import google.cloud.logging | ||
|
Member
Author
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. Moving this import inside the function, as the unit tests can fail when running locally, and the console is not authenticated with Google services |
||
|
|
||
| from shared.common.logging_utils import get_env_logging_level | ||
|
|
||
|
|
||
|
|
@@ -61,6 +59,8 @@ def init_logger(): | |
| if _logging_initialized: | ||
| return | ||
| try: | ||
| import google.cloud.logging | ||
|
|
||
| client = google.cloud.logging.Client() | ||
| client.setup_logging() | ||
| except Exception as error: | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -27,4 +27,5 @@ google-cloud-firestore | |
| google-cloud-bigquery | ||
|
|
||
| # Additional package | ||
| pycountry | ||
| pycountry | ||
| shapely | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] what does this have to do w big query?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that we have to cast(Geopolygon.geometry, Geography(srid=4326)) due to the original values from BigQuery tables being Geography instead of geometry