Warn when a dataset carries columns that match no variable - #531
Merged
Conversation
Fixes #530. Both dataset-load branches in Simulation.build_from_dataset silently dropped columns whose variable name is not in the tax-benefit system — one carried an explicit "Silently skip" comment. That makes any country-model input removal or rename silently zero the affected data for every existing dataset (the blocker for policyengine-us#9275's deprecated-input removals). Collect the skipped column names in both branches and emit one aggregated warning naming them (first ten, plus a count), so a version-mismatched dataset announces itself instead of loading as if nothing happened. Known columns load exactly as before, and clean datasets stay quiet — both covered by new tests on the flat-file path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #530.
Both dataset-load branches in
Simulation.build_from_datasetsilently dropped columns whose variable name isn't in the tax-benefit system — one carried a literal# Silently skip.comment. Consequence: any country-model input removal or rename silently zeroes that data for every existing dataset, which is the blocker behind policyengine-us#9275's staged removal of deprecated inputs (context: policyengine-us#9276, microcosm#673).This collects the skipped names in both branches and emits one aggregated warning naming them (first ten + count) after the load, e.g.:
Behavior is otherwise unchanged: known columns load exactly as before, unknown ones are still skipped (not fatal), and clean datasets stay quiet. Tests cover the warn-and-still-load case and the no-false-positive case on the flat-file path (
Dataset.from_dataframe+ country-templateMicrosimulation); the TIME_PERIOD_ARRAYS branch shares the same accumulator.A
strictmode that raises instead (for certification harnesses) is left as a follow-up if wanted — #530 sketches it.🤖 Generated with Claude Code