Add version-to-version data quality and drift checks - #181
Draft
developer-rpai wants to merge 1 commit into
Draft
developer-rpai wants to merge 1 commit into
developer-rpai wants to merge 1 commit into
Conversation
New cfa.dataops.quality module: Pandera schemas validate a single version's shape, but nothing checks that a new version still looks like the dataset it claims to be. Adds seven checks (freshness, row count, columns, dtypes, null rates, numeric drift, categorical values) aggregated into a QualityReport with raise_on_failure() for CI gating, plus a `python -m cfa.dataops.quality` CLI that exits non-zero on failure. Includes 47 tests (incl. doctests, following the repo's --doctest-modules convention), docs/data_quality.md, mkdocs nav entry, and a changelog entry. Relevant to CDCgov#148 (Quality Assurance and Testing epic).
This branch has not been deployed
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.
What this adds
Pandera schemas (per-dataset, in catalog repos) validate a single version's
shape. Nothing in
cfa.dataopschecks that a new version still looks likethe dataset it claims to be. This PR adds a reusable
cfa.dataops.qualitymodule for version-to-version checks:freshness— newest record withinmax_age_daysof the reference daterow_count— new version non-empty and withinmax_change_ratioof oldcolumns— no unexpected added/missing columnsdtypes— shared columns kept the same dtypenull_rates— per-column null fractions stable withinmax_deltanumeric_drift— column means stable withinmax_std_shiftold-std unitscategorical_values— no new/vanished categories in string columnsResults aggregate into a
QualityReport(.passed,.failed,.summary(),.as_dict(),.raise_on_failure()for CI gating), plus apython -m cfa.dataops.quality --new/--old/--configCLI that exits non-zeroon failure. Docs in
docs/data_quality.md, changelog entry included.Relevant to #148 (Quality Assurance and Testing epic).
How it was tested
tests/test_quality.py, including doctests (repo runs--doctest-moduleson the package):47 passedruff checkandruff format --check: cleantest_quality,test_soda,test_utils_*):99 passed. Note: several existing test modules cannot be collected inthis sandbox (missing
mako/pydantic/rich/tomli); that is apre-existing environment limitation, unrelated to this change.
pandas+ stdlib, so it adds no newdependencies.
Open questions for reviewers
cfa.dataops.qualitythe right home, or would you prefer this under adifferent module name?
Pandera-based validation in catalog repos is pandas-based?
Draft PR — happy to rework based on feedback before review.