feat(transducer): backfill data_maturity on acoustic (Wellntel) observations - #868
Merged
Merged
Conversation
Revision b2c3d4e5f6a7 backfilled data_maturity from nma_waterlevelscontinuous_pressure_qced. Acoustic readings have no such flag -- AMPAPI's WaterLevelsContinuous_Acoustic table has no QCed column -- so all 394,086 of them were skipped, which is the entire Wellntel record (BDMS-1169). Rows are matched on nma_waterlevelscontinuous_acoustic_global_id rather than on a NULL pressure flag: the global id is written by the acoustic transferer on every row and never by the pressure one, so it identifies provenance instead of merely the absence of evidence. Only rows whose data_maturity is still NULL are touched, so re-running is a no-op and a maturity set deliberately since -- by the hydrograph corrector, or by a later migration once the acoustic QC history is known -- is left alone rather than reset to the blanket value. The value itself is a recorded decision, not a derivation; there is no QC field in the acoustic legacy schema to read. The transfer's review_status='approved' blocks are not evidence for it, since those come from PublicRelease, which describes visibility rather than review. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Coverage✅ 79.04% total — gate is 75%. Coverage for the Python files changed in this PR
|
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 a data migration setting
data_maturityon the 394,086 acoustic (Wellntel) transducer observations that alembic revisionb2c3d4e5f6a7left NULL. Closes the gap reported in BDMS-1169.Why they were NULL
b2c3d4e5f6a7backfilled maturity fromnma_waterlevelscontinuous_pressure_qced, the AMPAPI flag recording whether a reading was quality controlled. Acoustic readings have no such flag — AMPAPI'sWaterLevelsContinuous_Acoustictable has noQCedcolumn at all — so every acoustic row was skipped. That is the entire Wellntel record: 394,086 rows, 54 wells, 176 deployments.Verified against a clone of production that the two cohorts are the same set, with no overlap:
What it does
Matches on provenance, not on absence.
acoustic_global_idis written byWaterLevelsContinuousAcousticTransferer._legacy_payloadon every acoustic row and never by the pressure transferer, so it says "this row came from the acoustic table" rather than "this row has no pressure QC flag". The two happen to select the same rows today; only the first stays correct if a future loader writes rows with neither.Only touches rows that are still NULL. Re-running is a no-op, and a maturity set deliberately since — by the hydrograph corrector, or by a later migration once the acoustic QC history is known — is left alone rather than reset to the blanket value.
The value is a recorded decision, not a derivation. There is no QC field in the acoustic legacy schema to read, so nothing here computes the answer. The docstring says so explicitly, and notes that the transfer's
review_status='approved'blocks are not evidence for it — those are derived fromPublicRelease, which every acoustic source row carries and which describes visibility rather than review. Worth a look from whoever owns the continuous record; BDMS-1169 is still open on whether the Wellntel data has been QCed and by what process.alembic_revision="b2c3d4e5f6a7", so the runner refuses to execute against a database without the column.Tests
Two added to
tests/test_data_migrations.py:5 passedand4 passedlocally.MODE=developmentis needed because a.envwithMODE=stagingtripsassert_auth_configuration()at import; unrelated to this change.Not covered
Nothing in CD runs data migrations (
CD_staging.yml/CD_production.ymlrunalembic upgrade headand stop), so merging this applies nothing. It needsoco data-migrations runby hand or adata_migrations.ymldispatch.Could not dry-run against real data: the local production clone is at alembic
b6c7d8e9f0a1, which predatesdata_maturity, so the column does not exist there and the runner's guard correctly rejects it. The 394,086 row count is confirmed from the provenance column, which does exist.Related, not fixed here
While confirming the cohort, found that the continuous transfer silently drops readings — BDMS-1186 (73,113 acoustic), BDMS-1188 (318,165 pressure, ten
WS-wells with nothingrow), BDMS-1187 (~22k conflicting duplicate-timestamp rows). This PR sets maturity on the rows that did load; it does not load the missing ones.🤖 Generated with Claude Code