Skip to content

CensusCountyBusinessPatterns: optimize pipeline runtime and update validation - #2219

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

kartik-s21 wants to merge 60 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
@balit-raibot
balit-raibot self-requested a review September 17, 2026 03:23
balit-raibot and others added 3 commits September 17, 2026 03:24
…g and validation

- Fix [P1] empty shard pattern: add shopt -s nullglob, check for generated shards, and abort with exit 1 if no shards exist.
- Fix [P1] zero-observation check: verify observation data exists beyond CSV header via line count > 1.
- Fix [P1] operational counters: restore counters directory, pass --output_counters to stat_var_processor.py, clean up on failure, and add counters/* to manifest.json source_files.
- Fix [P2] runtime bottleneck: add safe bounded parallelism (default 8 workers) using bash wait -n job pool with fail-fast error propagation.
- Fix [P2] shell robustness: add set -euo pipefail, quote all variable expansions in split_csv, and verify split succeeds.
- Fix [P3] diagnostic logging: fix error message referencing SHARD_DIR instead of INPUT_DIR.
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.

3 participants