Repository navigation
[India_RBI_State_Statistics] Modified download script and handle deletions - #2201
Krishnam24maheshwari wants to merge 18 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the RBI state statistics import pipeline by refactoring the preprocessing script to write to a temporary directory, adding unit tests, updating place mappings, and introducing a validation configuration. The reviewer feedback highlights several issues: df.map incorrectly converts NaN values to 'nan' strings; mapping combined regions like 'Haryana, Delhi & Chandigarh' to Haryana's ID (Q1174) is incorrect; the Wikidata ID for NCT of Delhi should be updated to Q9357528 for AA1 level data; and using a broad wildcard pattern for node_mcf in manifest.json is inefficient and should be scoped to specific directories.
Krishnam24maheshwari
left a comment
There was a problem hiding this comment.
done
a31e802 to
0ede682
Compare
In this PR we fix import execution failures, data corruption issues, and deletion handling in the India_RBI_State_Statistics import pipeline.
Problems Addressed:
rbi_download.pyhad a hard dependency on remote GCS configuration, crashing in environments without GCS access or ADC credentials.rbi.org.inlacked browser User-Agent headers, causing HTTP 403 / throttling rejections; individual table downloads were not isolated; and partial/corrupt files could be left in the working directory.*,@) caused malformed or literal"nan"string values.2015.0) failed to match integer string keys ("2015") in PVMaps, dropping observations.applymapcalls caused runtime errors across different pandas versions.run.sh:--input_data=$SCRIPT_PATH/input_files/agriculture/*.xlsxwas unquoted, causing Bash to expand the 42 matched files as positional arguments and silently dropping 41 tables (and 7 of 8 tables in price_and_wages).wikidataId/Q1352(Chennai) inrbi_places_resolver.csv.replace('*', '')) caused "Kolkata" and "Chennai" to miss cache entries inrbi_places_resolver.csv(Kolkata**,Chennai**).Changes Made:
1.
rbi_download.py&configs.json:configs.jsonby default, with automatic fallback if remote GCS paths are unreachable.requests.Session()withurllib3.util.Retry(4), status forcelists (429, 500, 502, 503, 504), pre-warmed portal cookies, and browser headers (User-Agent,Accept,Accept-Language) to prevent HTTP 403 blocks.PK\x03\x04ZIP signature) and usedtempfile.TemporaryDirectorywithos.replaceto prevent partial or corrupted downloads.force_downloadpreserves existing files until the new download is verified.clean_cell: Stripped footnote characters (*,@), trimmed whitespace, and converted empty/'nan'strings to true NaN.safe_to_numeric: Normalized numeric and float-coerced year headers (2015.0→2015) so they match integer keys in PVMaps._apply_map()helper supporting bothdf.map(pandas ≥ 2.1) anddf.applymap(pandas < 2.1).2.
run.sh:--input_data="$SCRIPT_PATH/input_files/agriculture/*.xlsx"and--input_data="$SCRIPT_PATH/input_files/price_and_wages/*.xlsx"in quotes sostat_var_processor.pyexpands and processes all 42 agriculture and 8 price/wage tables.COUNTERS_PATH=$SCRIPT_PATH/countersand appended--output_countersto all 18 processing commands.EXIT_STATUS=$?; exit $EXIT_STATUS.3. Place Mappings & PVMaps:
wikidataId/Q1353inrbi_places_resolver.csv.dcid:HaryanaDelhiChandigarhinenvironment_pvmap.csv.IndexScore_SustainableDevelopmentGoal.4.
manifest.json& Dev Verification:dev_verification_nodes.mcfundersource_filesandnode_mcffor the dev verification pipeline (datcom-import-test) to eliminate unreleased schema reference errors during dev testing. This file will be removed upon companion schema submission prior to final merge.counters/*.csvtosource_files.5. Tests & Fixtures:
rbi_download_test.pycovering download retries, corrupted payloads, HTTP 404s, and header conversions.testdata/environment_output.csvwith valid observation rows.6. Validation Config & Deletion Handling:
0.1%deletion threshold maintained invalidation_config.json.ImportStatus.STAGING. In production, the standard 0.1% threshold is enforced; upon the initial baseline reset run, the new output will be promoted aslatest_version.txt, after which subsequent weekly runs execute with 0% deletions.dcid:HaryanaDelhiChandigarh, NCT of Delhi), unit conversions (Hectare to MetricTon for fruits), and official RBI retrospective statistical revisions.Validation Reports (Cloud Batch Test Run):
input0 : https://console.cloud.google.com/storage/browser/_details/datcom-import-test/statvar_imports/database_on_indian_economy/india_rbi_state_statistics/India_RBI_State_Statistics/2026_10_12T05_25_11_249377_07_00/input0/validation/validation_output.csv?project=datcom-infosys-dev
input1 : https://console.cloud.google.com/storage/browser/_details/datcom-import-test/statvar_imports/database_on_indian_economy/india_rbi_state_statistics/India_RBI_State_Statistics/2026_10_12T05_25_11_249377_07_00/input1/validation/validation_output.csv?project=datcom-infosys-dev
input2 : https://console.cloud.google.com/storage/browser/_details/datcom-import-test/statvar_imports/database_on_indian_economy/india_rbi_state_statistics/India_RBI_State_Statistics/2026_10_12T05_25_11_249377_07_00/input2/validation/validation_output.csv?project=datcom-infosys-dev
input3 : https://console.cloud.google.com/storage/browser/_details/datcom-import-test/statvar_imports/database_on_indian_economy/india_rbi_state_statistics/India_RBI_State_Statistics/2026_10_12T05_25_11_249377_07_00/input3/validation/validation_output.csv?project=datcom-infosys-dev
input4 : https://console.cloud.google.com/storage/browser/_details/datcom-import-test/statvar_imports/database_on_indian_economy/india_rbi_state_statistics/India_RBI_State_Statistics/2026_10_12T05_25_11_249377_07_00/input4/validation/validation_output.csv?project=datcom-infosys-dev
input5 : https://console.cloud.google.com/storage/browser/_details/datcom-import-test/statvar_imports/database_on_indian_economy/india_rbi_state_statistics/India_RBI_State_Statistics/2026_10_12T05_25_11_249377_07_00/input5/validation/validation_output.csv?project=datcom-infosys-dev
input8 : https://console.cloud.google.com/storage/browser/_details/datcom-import-test/statvar_imports/database_on_indian_economy/india_rbi_state_statistics/India_RBI_State_Statistics/2026_10_12T05_25_11_249377_07_00/input8/validation/validation_output.csv?project=datcom-infosys-dev
input9 : https://console.cloud.google.com/storage/browser/_details/datcom-import-test/statvar_imports/database_on_indian_economy/india_rbi_state_statistics/India_RBI_State_Statistics/2026_10_12T05_25_11_249377_07_00/input9/validation/validation_output.csv?project=datcom-infosys-dev