Skip to content

CensusCountyBusinessPatterns: optimize pipeline runtime and update validation - #2219

Open
kartik-s21 wants to merge 57 commits into
datacommonsorg:masterfrom
kartik-s21:fix-census-cbp-validation
Open

kartik-s21 wants to merge 57 commits into
datacommonsorg:masterfrom
kartik-s21:fix-census-cbp-validation

Conversation

@kartik-s21

@kartik-s21 kartik-s21 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

This PR resolves validation failures and major performance bottlenecks in CensusCountyBusinessPatterns:

Fault Tolerance & Reliability:

  • Added automatic retry loops (up to 3 attempts with 15s delay) and cleanup of partial output artifacts for each shard in shard_input_csv.sh.
  • Added non-empty output validation ([ -s "$output_file" ]) and fail-fast termination (exit 1) if any shard fails after all attempts, preventing silent data drops.

Verification

  • PYTHONPATH=scripts/census_county_business_patterns python3 scripts/census_county_business_patterns/censuscountybusinesspatterns_test.py (Passed)
  • python3 -m py_compile scripts/census_county_business_patterns/main.py (Passed)
  • bash -n scripts/census_county_business_patterns/shard_input_csv.sh (Passed)
  • python3 -m json.tool scripts/census_county_business_patterns/validation_config.json (Passed)
  • Cloud Batch Job Run (test env) - link
  • Validation Output - link
  • CRA Report - link
  • Postmortem Report - link

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces parallel processing for downloading and processing Census County Business Patterns data, caches the StatVars MCF locally to optimize performance, and removes golden data validation checks. The review feedback highlights several critical improvement opportunities: streaming files directly in main.py to avoid potential Out-Of-Memory (OOM) errors during parallel execution, tracking and failing fast on sharding failures in Step 1 of shard_input_csv.sh, and ensuring proper error propagation inside the split_csv shell function.

Comment thread scripts/census_county_business_patterns/main.py Outdated
Comment thread scripts/census_county_business_patterns/shard_input_csv.sh Outdated
Comment thread scripts/census_county_business_patterns/shard_input_csv.sh
@kartik-s21
kartik-s21 force-pushed the fix-census-cbp-validation branch from 87e0fc4 to 34050f0 Compare September 11, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants