danparshall / danparshall/lobby_analysis
NY: download_bulk_csv output (whole-view + display headers) is pipeline-incompatible; download_resource_csv is the real primary path
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Summary
io/ny/acquire.download_bulk_csv is documented as "the primary path" for NY acquisition, but its output cannot feed the Phase-2 pipeline as-built. Discovered during the Phase-3 real pull (ny-disclosure-explore).
Two concrete problems
-
Whole-view, not year-scoped. It hits
/api/views/<id>/rows.csv?accessType=DOWNLOAD, which dumps the entire view.qym9-xzj6("Client Semi-Annual Report Beginning 2019") is 66.9M rows across 2019–2026 — 2025 alone is 11.2M. There is no$whereon that endpoint, so "pull 2025" is impossible through it. The whole-view export is 41 columns wide and streams ~0.9–3.2 MB/s → roughly ~55 GB / multi-hour, and_build_graindoes a single in-memorypd.read_csv(infeasible on a 16 GB machine). -
Display-name headers, not field names. The bulk export header row is human-readable display names (
Form Submission ID,Type of Lobbying Focus,Current Period Compensation), not the SODA field names (form_submission_id,type_of_lobbying_focus,current_period_compensation) thatcolumns.COLUMN_MAPSandgrain.collapse_to_filing_grainrequire. Feeding bulk-export output to the pipeline wouldKeyErrorin grain-collapse. The NY test fixtures were captured from/resource/<id>.json(field names), so the suite is green while this real-data path was never wired end-to-end — the egress block hid it.
Resolution (this branch)
Added acquire.download_resource_csv + resource_csv_url (SODA /resource/<id>.csv endpoint, supports $select/$where/$order/$limit, returns field-name headers), with 7 behavior tests. Phase 3 pulls 2025 via that path: 9 projected columns (only what the pipeline consumes), $where=reporting_year='2025' → ~3.17 GB, pipeline-compatible headers.
Follow-up to decide
- Deprecate or repurpose
download_bulk_csv? It still works as a generic whole-view dumper, but it's mislabeled as "primary" and its output is pipeline-incompatible. Options: (a) demote its docstring to "raw whole-view archival dump only, not pipeline input"; (b) remove it if nothing needs a whole-view dump; (c) add a display-name→field-name header remap shim if a whole-view path is ever wanted. - The single-request
download_resource_csvstream has no mid-download checkpoint (resume-skip is whole-file). Fine for a re-fetchable static dataset, but if larger pulls prove flaky, add keyset/range pagination (note:form_submission_idis non-unique ~1,300×, so any paging must slice by id range, never split a filing across a page boundary).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in io/ny/acquire at download_bulk_csv, download_resource_csv, and resource_csv_url, then inspect columns.COLUMN_MAPS and grain.collapse_to_filing_grain. Review the seven resource CSV behavior tests and the Phase-3 pull configuration. Done means deciding and documenting whether the bulk path is deprecated, removed, or adapted without breaking the pipeline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, data-engineering
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100