feat: add reverse geolocation strategy parameter#1309
Merged
davidgamez merged 10 commits intoAug 13, 2025
Conversation
davidgamez
marked this pull request as ready for review
August 11, 2025 17:08
jcpitre
reviewed
Aug 12, 2025
| The decorator logs the metrics using the provided logger or a default logger if none is provided. | ||
| Args: | ||
| metrics (tuple): Metrics to track. Options are "time", "memory", "cpu | ||
| logger (logging.Logger): Logger instance to log the metrics. If None, uses a default logger. |
Collaborator
There was a problem hiding this comment.
I'm a bit confused. It says here that we can pass a logger to the decorator, but in the code it uses the logger in the decorated function arguments. Maybe I'm misreading?
Member
Author
There was a problem hiding this comment.
Sorry, that was the first implementation, but I had issues using the logger as a parameter, so I removed it. Now I took out the documentation.
jcpitre
reviewed
Aug 12, 2025
| """ | ||
| logger.info("Processing geopolygons with per-point strategy.") | ||
| # Get Cached Geopolygons | ||
| feed_id, location_groups, stops_df = get_cached_geopolygons( |
Collaborator
There was a problem hiding this comment.
Nitpick: Maybe stopfs_df should be renamed unmatched_stops_df to correspond to the name of the returned value from get_cached_geopolygons and to distinguish it from the original stops_df.
jcpitre
approved these changes
Aug 13, 2025
jcpitre
left a comment
Collaborator
There was a problem hiding this comment.
Great addition for tracking metrics!
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:
This PR adds the strategy parameter to the reverse geolocation processor. The only strategy supported currently is
per-point. This is the already implemented algorithm that performs one reverse geolocation per geopositional point.Minor changes:
track_metricsannotation to log performance-related metricsPart of #1301
Expected behavior:
After this refactoring, the reverse geolocation should continue to work as it with no changes in the process.
From our AI friend
This pull request introduces several enhancements and refactorings to the reverse geolocation processing pipeline, focusing on improved configurability, extensibility, and observability. The main updates include the addition of a configurable reverse geocoding strategy, support for specifying the public/private status of output files, a new runtime metrics tracking decorator, and codebase refactoring for clarity and maintainability.
Configurability and Feature Additions:
ReverseGeocodingStrategyenum and support for specifying thestrategy(currently onlyper-point) in both the request and processing logic, making the reverse geolocation process more extensible. (functions-python/helpers/locations.py,functions-python/reverse_geolocation/src/parse_request.py,functions-python/reverse_geolocation/src/reverse_geolocation_processor.py) [1] [2] [3] [4] [5] [6] [7]publicparameter in requests, allowing control over whether generated GeoJSON files are public or private. (functions-python/reverse_geolocation/README.md,functions-python/reverse_geolocation/src/parse_request.py,functions-python/reverse_geolocation/src/reverse_geolocation_processor.py) [1] [2] [3] [4]Observability and Utility Improvements:
track_metricsdecorator to monitor time, memory, and CPU usage for key functions, improving runtime observability and debugging. (functions-python/helpers/runtime_metrics.py, [1] [2] [3]to_booleanutility for more robust type conversion and added a genericto_enumutility for safely converting values to enum members. (functions-python/helpers/transform.py) [1] [2]Refactoring and Documentation:
functions-python/reverse_geolocation/src/reverse_geolocation_processor.py,functions-python/reverse_geolocation/src/parse_request.py) [1] [2] [3]functions-python/reverse_geolocation/.coveragerc,functions-python/reverse_geolocation/requirements.txt,functions-python/reverse_geolocation/requirements_dev.txt) [1] [2] [3]Testing tips:
Local testing
reverse_geolocation_process_verifier.pyfor local testingPlease make sure these boxes are checked before submitting your pull request - thanks!
./scripts/api-tests.shto make sure you didn't break anything