fix(dbt): honour on_low_score="fail" in FreshDataDbtTransform; unique audit files for same-alias models - #391
Merged
Conversation
… audit files for same-alias models on_low_score="fail" was ignored by FreshDataDbtTransform (#343): - run() only raised TrustGateError when fail_on_low_score=True, so with on_low_score="fail" a failing gate returned should_fail=True and the pipeline carried on. run() now raises when result.should_fail or when fail_on_low_score is set and the gate did not pass. The audit file is still written before raising. - run() takes a keyword-only raise_on_fail=True. gate_manifest calls run(raise_on_fail=False), so a failing model under on_low_score="fail" is recorded as failed and the run continues. The summary shape and the skipped/all_passed semantics are unchanged. Same-alias models overwrote each other's audit file (#344): - FreshDataDbtTransform gains audit_name, used as the audit file stem (<audit_name>_audit.json) instead of the table name. It is checked with _validate_audit_table_name when the transform is configured. - When output_dir is set, gate_manifest counts aliases across the models it gates (case-insensitively, since audit files may land on a case-insensitive filesystem). Models whose alias is shared are written to <schema>.<alias>_audit.json, or to <unique_id>_audit.json when the schema is missing or that name is still not unique. Other models keep <alias>_audit.json. An unsafe schema is rejected by the validator and recorded as that model's error. Closes #343 Closes #344
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
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.
Builds on #351 (merged); rebased onto
main.Summary
on_low_score="fail"ignored byFreshDataDbtTransform(#343)run()raisedTrustGateErroronly whenfail_on_low_score=True, so a failing gate underon_low_score="fail"returnedshould_fail=Trueand the pipeline carried on. It now raises whenresult.should_fail, or whenfail_on_low_scoreis set and the gate did not pass. The audit file is still written first.run(raise_on_fail=True).gate_manifestcallsrun(raise_on_fail=False), so a failing model is recorded as failed and the run continues. The summary shape and fix(cli): clean errors for malformed inputs and honest dbt-gate exit codes #351'sskipped/all_passedrules are unchanged.Same-alias models overwrote each other's audit file (#344)
FreshDataDbtTransformgainsaudit_name, used as the audit file stem. It is checked with_validate_audit_table_name.output_dir,gate_manifestcounts aliases across gated models (case-insensitively). Models that share an alias write<schema>.<alias>_audit.json, or<unique_id>_audit.jsonwhen the schema is missing or still not unique. Other models keep<alias>_audit.json. A schema that is not a valid file name is rejected and recorded as that model's error.docs/integrations.mddocumentson_low_score="fail",raise_on_failand the audit file names.Behaviour change:
FreshDataDbtTransform(on_low_score="fail").run()now raises on a failing gate; passraise_on_fail=Falseto get the result back.Tests
New
tests/test_integrations/test_dbt_transform_fail_audit.py(real SQLAlchemy + sqlite, schemas viaATTACH,tmp_path):on_low_score="fail"raises fromrun()and still writes the audit;run(raise_on_fail=False)returns the failing result;"warn"/"skip"don't raise; a passing gate never raises under either switch.gate_manifestunderon_low_score="fail"records failing models and gates every model.stagingandmartswrites two audit files with the right row counts; non-colliding models keep<alias>_audit.json; a schema-less collision falls back tounique_id, including a case-only collision.audit_namevalues ("",.,..,../orders,a/b,a\b,/abs) raiseValueErrorand nothing is written outside the output directory.Verification
ruff check .: passed; changed files areruff format-cleanmypy src/freshdata: no issuespytest -m "not online and not large"on the rebased branch: Python 3.12: 5150 passed, 13 skipped; Python 3.9: 5146 passed, 17 skippedCloses #343
Closes #344