Add NCSBE ETL pipeline, materialized voter views, and SQL agent (CLI + web)#1
Draft
Add NCSBE ETL pipeline, materialized voter views, and SQL agent (CLI + web)#1
Conversation
- Add VoterView (all statuses) and VoterEventView using pg.MaterializedView - Rename from MvVoterRegistration/MvVoterHistory; remove db_table/app_label - Fix SQL table refs: ncsbe_voter, ncsbe_voterevent - Add migration and model tests for both views
- Add LOGGING config; replace print() with logger.info() in loader - Add elapsed_timer() contextmanager; remove duplicate timing from loaders - Add --refresh-only flag to ncsbe etl command - Add conftest.py to sync materialized views in test DB - Draft README with setup and usage instructions
- Build minimal TSV fixtures (voter + history) and load via real COPY path - Assert rows appear in VoterView and VoterEventView after refresh - Test date casting and masked registr_dt → NULL
- Add pydantic-evals to dev dependencies - Define IsSelectQuery, IsInvalidRequest, NoPiiColumns evaluators - Define sql_gen_dataset with voter/off-topic test cases - Add TestSqlGenEvals with 3 focused tests
- Register llm marker in pyproject.toml - Add test_llm_judge_evals.py with no_pii and on_topic LLMJudge checks - Use settings.VOTER_REG_MODEL (local ollama) as judge model - All 3 tests pass against qwen3.5:9b
- Print sql_gen_agent system prompt and voter_agent instructions - Support --name sql_gen|voter to filter output - Add TestAgentPromptsCommand with 4 tests
- Add ReadOnlyAdmin base for materialized views (no add/change/delete) - VoterViewAdmin: exact-match ncid search, show_full_result_count=False - VoterEventViewAdmin: no search (ncid unindexed), show_full_result_count=False - Add TestVoterViewAdmin and TestVoterEventViewAdmin (12 tests)
- Add db_comment to key VoterView and VoterEventView columns - get_view_schema includes db_comment as inline SQL comments for the agent - Add `ncsbe comments` subcommand to print copy-pasteable db_comment suggestions from distinct column values - Add 6 focused tests covering schema comments and the new command
…_text to raw models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds initial end-to-end NC voter data ETL.
Summary