added golden USCensusPEP_PopulationEstimatebyRace#2048
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds several golden data CSV files and introduces a validation configuration file (validation_config.json) along with its reference in the manifest to enable automated validation checks for the US Census PEP population estimate by race import. Feedback on the changes highlights a critical filename mismatch in the validation configuration that would cause a file-not-found error, as well as recommendations to ensure all validation rules have unique rule_id values for clearer reporting.
…ing persistent Session and retries
…er imports to module level
…d format preprocess.py
…hs in validation_config.json
|
The refactoring of |
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces validation configurations and golden summary reports for US Census PEP population estimates by race. It updates preprocess.py to use a robust requests.Session with retry logic, fixes a bug in a string length check, sorts input files, and updates pandas operations to avoid deprecation warnings. Feedback is provided to extend the retry adapter configuration to cover both HTTP and HTTPS protocols.
| retries = Retry(total=5, | ||
| backoff_factor=1, | ||
| status_forcelist=[429, 500, 502, 503, 504], | ||
| raise_on_status=False) | ||
| session.mount('https://', HTTPAdapter(max_retries=retries)) |
There was a problem hiding this comment.
Currently, the retry adapter is only mounted to https:// URLs. If any input URLs or future URLs use http://, they will not benefit from the configured retry mechanism. It is safer and more robust to mount the adapter to both http:// and https:// protocols.
| retries = Retry(total=5, | |
| backoff_factor=1, | |
| status_forcelist=[429, 500, 502, 503, 504], | |
| raise_on_status=False) | |
| session.mount('https://', HTTPAdapter(max_retries=retries)) | |
| retries = Retry(total=5, | |
| backoff_factor=1, | |
| status_forcelist=[429, 500, 502, 503, 504], | |
| raise_on_status=False) | |
| adapter = HTTPAdapter(max_retries=retries) | |
| session.mount('http://', adapter) | |
| session.mount('https://', adapter) |
This PR includes:
To prevent intermittent run-time connection failures or GCS/Census endpoint timeouts:
failed requests (up to 5 retries, handling status codes 429, 500, 502, 503, 504 with exponential backoff).
the same robust timeout and retry safety.
To eliminate risk of unexpected behavior, performance side-effects, and standard Pandas warnings (such as SettingWithCopyWarning):
df.iloc[j, 0] = ....
column's underlying data type.
Fixed a critical logical/syntactical bug in checking filename lengths:
logical failures).
mismatched generation, or tests behaving differently on different filesystems.
recent and future Pandas versions.
PR checklist : https://docs.google.com/spreadsheets/d/1BzweR9Sj58j0H2_BweGTmfE4Z1lrjPZL8u1FS0kzCeg/edit?pli=1&gid=0#gid=0