truequery 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {truequery-0.2.0 → truequery-0.2.1}/PKG-INFO +1 -1
- {truequery-0.2.0 → truequery-0.2.1}/pyproject.toml +1 -1
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/__init__.py +1 -1
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/cli.py +60 -19
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/datasetup.py +11 -1
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/dataverify.py +31 -7
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/hook.py +38 -16
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/initfrom.py +14 -2
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/project.py +36 -14
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/report.py +2 -0
- truequery-0.2.1/src/truequery/safewrite.py +222 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/scaffold.py +36 -6
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/verify.py +17 -8
- {truequery-0.2.0 → truequery-0.2.1}/.gitignore +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/LICENSE +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/NOTICE +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/analyzers/__init__.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/analyzers/pandas_checks.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/analyzers/pandas_contracts.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/analyzers/project_checks.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/analyzers/sql.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/assertions.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/checks/__init__.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/checks/sql.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/contract_v2.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/engine.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/extractors/__init__.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/extractors/python_sql.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/keylookup.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/models.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/registry_impl.json +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/schema.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/schemas/contract-v2.schema.json +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/schemas/metric-v1.schema.json +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/schemas/tq-config.schema.json +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/settings.py +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/adhoc-limit-required.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/aggregate-before-export.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/consumer-cost-guard.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/consumer-reads-marts.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/dashboard-query-budget.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/dashboard-refresh-schedule.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/deterministic-export-order.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explicit-timezone-consumers.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-answer-carries-reproducible-query.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-caveats-and-unchecked-stated.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-day-boundaries-and-partial-periods.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-experiment-readout-follows-plan.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-freshness-and-coverage-checked.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-inspect-distributions-and-examples.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-join-row-count-checks.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-null-aware-negative-filters.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-question-metric-grain-stated.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-rates-not-counts-across-segments.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-reconcile-to-known-total.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/explore-reuse-governed-metric.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/export-row-cap.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/freshness-displayed.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/no-deep-offset.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/parameterized-dashboard-filters.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/reverse-etl-idempotent-keys.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/reverse-etl-pii-consent.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/consume/reverse-etl-schema-contract.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/accuracy-proxy-or-unmeasurable.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/audits-blocking-every-run.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/checks-versioned-with-code.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/completeness-declare-missing-sentinels.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/completeness-fill-rate-thresholds.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/completeness-not-null-required-columns.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/completeness-table-not-empty.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/consistency-cross-column-row-rules.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/consistency-no-orphan-keys.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/consistency-paired-aggregate-reconciliation.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/expected-absence-counted-as-missing.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/schema-conformance-checked-on-read.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/undeclared-status-value.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/unenforced-constraints-are-tested.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/uniqueness-composite-grain.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/uniqueness-key-no-duplicates.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/unit-tests-with-fixtures.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/validity-allowed-value-sets.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/validity-enforce-model-contracts.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/dq/validity-range-format-type-rules.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/audit-columns-or-snapshots.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/column-grants-for-pii.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/declared-model-owner.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/description-coverage-for-shared-models.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/erasure-path-documented.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/exposures-registered.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/group-private-access.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/least-privilege-grants.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/lineage-from-declared-sources.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/mesh-public-contracts-only.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/no-bypassrls-roles.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/no-public-privileges.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/no-raw-pii-in-seeds.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/pii-classification-declared.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/production-pii-not-in-dev.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/redacting-views-for-pii.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/retention-declared.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/gov/row-policy-for-sensitive-tables.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/cap-intake-cost-and-volume.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/cdc-replica-identity-required.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/checkpoint-streaming-intake.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/choose-batch-vs-streaming-deliberately.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/declare-source-freshness.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/dedupe-on-natural-key-before-append.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/handle-schema-drift-explicitly.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/idempotent-batch-loads.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/isolate-source-failures.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/landing-rebuildable-from-source.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/monitor-cdc-lag-and-slots.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/pin-connector-and-schema-versions.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/pin-file-format-options.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/propagate-deletes-explicitly.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/quarantine-invalid-rows-at-intake.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/raw-landing-append-only.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/reconcile-row-counts-per-load.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/record-file-lineage-at-intake.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/reference-sources-not-raw-tables.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/require-completeness-marker.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/scan-pii-at-landing.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/seeds-small-static-only.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/test-intake-against-fixtures.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ingest/watermark-and-late-data-policy.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/dbt-contract-enforced.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/delete-handling-incremental.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/explicit-column-lists.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/full-refresh-parity.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/grain-preserved-joins.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/idempotent-reexec.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/incremental-lookback-window.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/incremental-watermark-filter.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/jinja-macro-determinism.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/jinja-no-nested-curlies.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/materialization-choice.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/merge-source-deduped.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/microbatch-event-time.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/null-join-keys-excluded.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/snapshot-scd2-validity.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/snapshot-strategy-choice.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/staging-no-business-logic.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/surrogate-keys-stable.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/model/unique-key-merge-key.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/breaking-change-categorization.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/ci-pr-checks-required.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/ci-slim-builds-only-changed.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/cost-estimate-before-run.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/cost-guardrail-confidence-levels.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/dev-environment-expiry.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/disposable-dev-environments.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/drift-detection-history-first.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/full-refresh-approval.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/model-versioning-breaking-changes.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/plan-preview-before-apply.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/post-deploy-data-validation.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/pre-destructive-snapshot.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/prod-credentials-isolation.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/run-artifact-retention.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/ops/staged-upgrades-with-backup.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/concurrency-pools-and-limits.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/dag-ci-parse-and-unit-tests.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/data-aware-scheduling-over-polling.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/declared-asset-lineage.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/deferrable-sensors-with-timeout.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/explicit-catchup-policy.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/explicit-schedule-timezone.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/failure-alert-routing.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/idempotent-backfill-windowing.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/idempotent-retries-with-limits.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/light-dag-parse-no-heavy-top-level.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/no-circular-dependencies.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/partitioned-assets-windowing.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/sla-deadline-alerts.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/task-atomicity-no-partial-writes.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/orch/task-timeout-execution-limit.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/airflow-isolate-task-dependencies.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/dagster-asset-declared-dependencies.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/dagster-io-manager-not-manual-io.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/dagster-resources-for-external-clients.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/dbt-python-model-contract.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/deterministic-model-outputs.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/hook-adapter-connection-lifecycle.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/idempotent-task-logic.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/no-n-plus-one-queries-in-loops.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-dedupe-unstable-sort.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-fillna-zero-on-money.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-filter-before-collect.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-groupby-dropna.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-groupby-first-mixes-rows.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-merge-validate.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-no-chained-assignment.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-no-row-loop-mutations.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-read-csv-contract-dtype.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-to-sql-replace.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pandas-write-mode-violation.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/pin-pipeline-dependencies.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/sqlmesh-audit-python-outputs.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/py/sqlmesh-python-model-execution-context.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/aggregation-type-matches-additivity.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/conversion-metrics-window-bounds.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/count-distinct-uses-entity-key.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/cumulative-metrics-time-spine.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/derived-metrics-compose-from-governed.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/description-and-ownership-per-metric.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/dimension-naming-conventions.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/entity-primary-key-declared.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/join-paths-declared-via-entities.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/metric-drift.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/metric-filters-declared-not-hidden.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/metric-grain-declaration.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/metric-smoke-test-on-change.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/no-fanout-double-counting.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/no-metric-defined-off-staging.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/null-handling-in-aggregations.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/percentile-metrics-use-approximate.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/ratio-metrics-divide-after-aggregation.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/relative-path-base-mismatch.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/saved-query-canonical-slices.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/semantic-model-validates.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/single-governed-metric-definition.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/time-dimension-standardized.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/timezone-mismatch.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/unit-consistency.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sem/unit-mismatch.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/accidental-cross-join.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/average-of-ratios.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/between-date-on-timestamp.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/case-without-else-in-aggregate.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/count-star-after-left-join.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/distinct-dedup-bandaid.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/explore-limit-is-not-a-sample.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/explore-profile-filter-columns.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/fanout-join-pre-aggregation.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/group-by-bare-column.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/insert-explicit-column-list.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/integer-division-truncation.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/keyset-pagination.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/left-join-null-rejecting-where.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/limit-requires-order-by.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/natural-join-explicit-keys.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/negative-filter-drops-nulls.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/nondeterministic-merge-keys.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/not-in-nullable-subquery.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/null-equality-comparison.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/random-sampling-no-sort.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/row-number-dedupe-tiebreaker.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/sargable-filter-bare-column.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/set-operation-column-position.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/unguarded-update-delete.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/sql/union-all-default.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/README.md +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/cluster-on-frequent-filters-joins.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/compact-small-files-optimize.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/declare-not-null-check-constraints.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/declare-sort-order-for-range-queries.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/enable-change-feed-for-incremental-consumers.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/evolve-partitions-by-metadata-not-rewrite.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/explicit-physical-types-no-implicit-casts.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/full-refresh-by-replace-not-delete-insert.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/incremental-watermark-partition-alignment.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/no-high-cardinality-partition-column.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/partition-expiration-retention-policy.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/partition-on-filter-column.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/partition-predicate-required.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/prefer-auto-liquid-clustering-over-manual-tune.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/rewrite-manifests-and-stats-periodically.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/single-open-format-per-medallion-layer.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/time-travel-retention-explicit.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/use-transient-temporary-for-ephemeral.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/standard/store/vacuum-expire-snapshots-with-retention-floor.yaml +0 -0
- {truequery-0.2.0 → truequery-0.2.1}/src/truequery/std_registry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: truequery
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: TrueQuery engine: offline, deterministic checks for SQL and pandas code that silently return the wrong answer
|
|
5
5
|
Project-URL: Homepage, https://github.com/Analytically-ai/truequery
|
|
6
6
|
Project-URL: Issues, https://github.com/Analytically-ai/truequery/issues
|
|
@@ -7,7 +7,7 @@ build-backend = "hatchling.build"
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "truequery"
|
|
10
|
-
version = "0.2.
|
|
10
|
+
version = "0.2.1"
|
|
11
11
|
description = "TrueQuery engine: offline, deterministic checks for SQL and pandas code that silently return the wrong answer"
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.11"
|
|
@@ -12,6 +12,7 @@ from truequery import engine as E
|
|
|
12
12
|
from truequery import hook
|
|
13
13
|
from truequery import project as P
|
|
14
14
|
from truequery import report as RP
|
|
15
|
+
from truequery import safewrite
|
|
15
16
|
from truequery import schema
|
|
16
17
|
from truequery import settings as S
|
|
17
18
|
from truequery import std_registry
|
|
@@ -372,23 +373,45 @@ def cmd_init(args: argparse.Namespace) -> int:
|
|
|
372
373
|
config = P.default_config(stack, dialect)
|
|
373
374
|
wrote, kept = [], []
|
|
374
375
|
data_md = os.path.join(root, "DATA.md")
|
|
375
|
-
|
|
376
|
-
with open(data_md, "w", encoding="utf-8") as handle:
|
|
377
|
-
handle.write(P.render_data_md(config))
|
|
378
|
-
wrote.append(data_md)
|
|
379
|
-
else:
|
|
380
|
-
kept.append(data_md)
|
|
376
|
+
write_data_md = args.force or not os.path.exists(data_md)
|
|
381
377
|
contracts_dir = os.path.join(root, "contracts")
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
378
|
+
skipped_models: list[tuple[str, str, str]] = []
|
|
379
|
+
seeds = P.seed_plan(root, skipped_models)
|
|
380
|
+
try:
|
|
381
|
+
# Never through a link: every target is checked before anything
|
|
382
|
+
# is written.
|
|
383
|
+
if write_data_md:
|
|
384
|
+
safewrite.check(root, data_md)
|
|
385
|
+
safewrite.check(root, contracts_dir)
|
|
386
|
+
for dest, _spec, _source in seeds:
|
|
387
|
+
safewrite.check(root, dest)
|
|
388
|
+
if drafts is not None:
|
|
389
|
+
for dest in initfrom.targets(root, drafts):
|
|
390
|
+
safewrite.check(root, dest)
|
|
391
|
+
if write_data_md:
|
|
392
|
+
with safewrite.open_text(root, data_md, "w") as handle:
|
|
393
|
+
handle.write(P.render_data_md(config))
|
|
394
|
+
wrote.append(data_md)
|
|
395
|
+
else:
|
|
396
|
+
kept.append(data_md)
|
|
397
|
+
safewrite.makedirs(root, contracts_dir)
|
|
398
|
+
# Contracts hold the team's confirmed answers: seeded when missing,
|
|
399
|
+
# never overwritten, not even with --force.
|
|
400
|
+
for path in P.seed_contracts(root, seeds):
|
|
401
|
+
wrote.append(path)
|
|
402
|
+
drafted: list[str] = []
|
|
403
|
+
if drafts is not None:
|
|
404
|
+
drafted = initfrom.write(root, drafts)
|
|
405
|
+
except safewrite.UnsafePathError as exc:
|
|
406
|
+
print(f"truequery: init: nothing written: {exc}", file=sys.stderr)
|
|
407
|
+
return EXIT_ERROR
|
|
387
408
|
summary = {"stack": stack, "dialect": dialect, "wrote": wrote,
|
|
388
409
|
"kept": kept}
|
|
389
|
-
|
|
410
|
+
if skipped_models:
|
|
411
|
+
summary["skipped_models"] = [
|
|
412
|
+
{"name": n, "source": src, "reason": why}
|
|
413
|
+
for n, src, why in skipped_models]
|
|
390
414
|
if drafts is not None:
|
|
391
|
-
drafted = initfrom.write(root, drafts)
|
|
392
415
|
summary["from"] = initfrom.public(drafts, drafted)
|
|
393
416
|
if args.sarif:
|
|
394
417
|
print(RP.render_sarif([], ENGINE_VERSION))
|
|
@@ -399,6 +422,9 @@ def cmd_init(args: argparse.Namespace) -> int:
|
|
|
399
422
|
print(f"wrote {path}")
|
|
400
423
|
for path in kept:
|
|
401
424
|
print(f"kept existing {path} (use --force to overwrite)")
|
|
425
|
+
for name, src, why in skipped_models:
|
|
426
|
+
print(f"skipped dbt model {json.dumps(name)} in {src}: {why}, "
|
|
427
|
+
"so it can't be a contract file name")
|
|
402
428
|
print(f"init: stack={stack} dialect={dialect or 'auto'} "
|
|
403
429
|
f"({len(wrote)} wrote, {len(kept)} kept)")
|
|
404
430
|
if drafts is not None:
|
|
@@ -412,7 +438,7 @@ def cmd_scaffold(args: argparse.Namespace) -> int:
|
|
|
412
438
|
root = os.path.abspath(".")
|
|
413
439
|
try:
|
|
414
440
|
result = SC.plan(args.contracts, args.out, root)
|
|
415
|
-
written = SC.write(result, args.force)
|
|
441
|
+
written = SC.write(result, args.force, root)
|
|
416
442
|
except SC.ScaffoldError as exc:
|
|
417
443
|
print(f"truequery: scaffold: {exc}", file=sys.stderr)
|
|
418
444
|
return EXIT_ERROR
|
|
@@ -803,8 +829,14 @@ def _rules_set(args: argparse.Namespace, root) -> int:
|
|
|
803
829
|
print("truequery: no DATA.md here; run `truequery init` first "
|
|
804
830
|
"(or use --scope user)", file=sys.stderr)
|
|
805
831
|
return EXIT_ERROR
|
|
806
|
-
|
|
807
|
-
|
|
832
|
+
new_text = S.data_md_with_rule(text, slug, updates)
|
|
833
|
+
try:
|
|
834
|
+
with safewrite.open_text(root, data_md, "w") as handle:
|
|
835
|
+
handle.write(new_text)
|
|
836
|
+
except safewrite.UnsafePathError as exc:
|
|
837
|
+
print(f"truequery: rules set: not written: {exc}",
|
|
838
|
+
file=sys.stderr)
|
|
839
|
+
return EXIT_ERROR
|
|
808
840
|
where = data_md
|
|
809
841
|
except ValueError as exc:
|
|
810
842
|
print(f"truequery: {exc}", file=sys.stderr)
|
|
@@ -981,8 +1013,12 @@ def cmd_ignore_add(args: argparse.Namespace) -> int:
|
|
|
981
1013
|
file=sys.stderr)
|
|
982
1014
|
return EXIT_ERROR
|
|
983
1015
|
state_dir = os.path.join(root, ".truequery")
|
|
984
|
-
os.makedirs(state_dir, exist_ok=True)
|
|
985
1016
|
ignores_path = os.path.join(state_dir, "ignores.json")
|
|
1017
|
+
try:
|
|
1018
|
+
safewrite.check(root, ignores_path) # never through a link
|
|
1019
|
+
except safewrite.UnsafePathError as exc:
|
|
1020
|
+
print(f"truequery: ignore add: not written: {exc}", file=sys.stderr)
|
|
1021
|
+
return EXIT_ERROR
|
|
986
1022
|
try:
|
|
987
1023
|
with open(ignores_path, encoding="utf-8") as handle:
|
|
988
1024
|
data = json.load(handle)
|
|
@@ -1000,8 +1036,13 @@ def cmd_ignore_add(args: argparse.Namespace) -> int:
|
|
|
1000
1036
|
del entry["stmt"], entry["offset"]
|
|
1001
1037
|
if entry not in entries:
|
|
1002
1038
|
entries.append(entry)
|
|
1003
|
-
|
|
1004
|
-
|
|
1039
|
+
try:
|
|
1040
|
+
safewrite.makedirs(root, state_dir)
|
|
1041
|
+
with safewrite.open_text(root, ignores_path, "w") as handle:
|
|
1042
|
+
json.dump(data, handle, indent=2)
|
|
1043
|
+
except safewrite.UnsafePathError as exc:
|
|
1044
|
+
print(f"truequery: ignore add: not written: {exc}", file=sys.stderr)
|
|
1045
|
+
return EXIT_ERROR
|
|
1005
1046
|
print(f"ignore added: {args.rule} on {path}:{line} "
|
|
1006
1047
|
f"(reason recorded)")
|
|
1007
1048
|
return EXIT_CLEAN
|
|
@@ -37,6 +37,7 @@ from typing import Any
|
|
|
37
37
|
import yaml
|
|
38
38
|
|
|
39
39
|
from truequery import project as P
|
|
40
|
+
from truequery import safewrite
|
|
40
41
|
from truequery import verify as V
|
|
41
42
|
|
|
42
43
|
SPEC = V.DUCKDB_SPEC
|
|
@@ -263,7 +264,8 @@ def record_answer(root: str, wanted: bool) -> str | None:
|
|
|
263
264
|
if not ok:
|
|
264
265
|
return UNSAFE
|
|
265
266
|
out = text[:match.start(1)] + new_body + text[match.end(1):]
|
|
266
|
-
|
|
267
|
+
# Never through a link (raises safewrite.UnsafePathError).
|
|
268
|
+
with safewrite.open_text(root, path, "w", newline="") as handle:
|
|
267
269
|
handle.write(out.replace("\n", "\r\n") if crlf else out)
|
|
268
270
|
return path
|
|
269
271
|
|
|
@@ -412,6 +414,14 @@ def status_lines(root: str, env: dict | None = None) -> list[str]:
|
|
|
412
414
|
def run_setup(args, root: str, env: dict | None = None,
|
|
413
415
|
runner=subprocess.run) -> int:
|
|
414
416
|
"""`truequery setup data [--yes | --no]`."""
|
|
417
|
+
data_md = os.path.join(root, "DATA.md")
|
|
418
|
+
if (args.yes or args.no) and os.path.lexists(data_md):
|
|
419
|
+
try: # checked before anything is installed or written
|
|
420
|
+
safewrite.check(root, data_md)
|
|
421
|
+
except safewrite.UnsafePathError as exc:
|
|
422
|
+
print(f"truequery: setup data: nothing changed: {exc}",
|
|
423
|
+
file=sys.stderr)
|
|
424
|
+
return 2
|
|
415
425
|
if args.no:
|
|
416
426
|
where = record_answer(root, False)
|
|
417
427
|
print("Not installing the data reader.")
|
|
@@ -18,6 +18,7 @@ import os
|
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
20
|
from truequery import project as P
|
|
21
|
+
from truequery import safewrite
|
|
21
22
|
from truequery import verify as V
|
|
22
23
|
|
|
23
24
|
LABEL = 13 # width of the receipt's first column
|
|
@@ -70,9 +71,21 @@ def run(root: str, datasets: list[str] | None = None,
|
|
|
70
71
|
|
|
71
72
|
evidence = None
|
|
72
73
|
if write_evidence and records:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
try:
|
|
75
|
+
path = V.append_evidence(root, records)
|
|
76
|
+
except OSError as exc:
|
|
77
|
+
# A link in `.truequery/` (UnsafePathError), or a folder where
|
|
78
|
+
# the log should be: nothing written, and the receipt says so.
|
|
79
|
+
# Exit codes don't change.
|
|
80
|
+
reason = str(exc) if isinstance(exc, safewrite.UnsafePathError) \
|
|
81
|
+
else (f"`.truequery/{V.EVIDENCE_FILE}` can't be written "
|
|
82
|
+
f"({exc.strerror or type(exc).__name__})")
|
|
83
|
+
evidence = {"path": None, "records": len(records),
|
|
84
|
+
"not_written": reason}
|
|
85
|
+
else:
|
|
86
|
+
if path:
|
|
87
|
+
evidence = {"path": P._rel(path, root),
|
|
88
|
+
"records": len(records)}
|
|
76
89
|
|
|
77
90
|
return {
|
|
78
91
|
"checked_at": now_dt.isoformat(),
|
|
@@ -681,10 +694,9 @@ def render_text(doc: dict, verbose: bool = False) -> str:
|
|
|
681
694
|
lines.append(f"{'Not checked':<{LABEL}}no contract points at local "
|
|
682
695
|
"data (`kind: files`, or a table with "
|
|
683
696
|
"`location.database`), so no data was read")
|
|
684
|
-
|
|
685
|
-
if
|
|
686
|
-
lines.append(f"{'Evidence':<{LABEL}}{
|
|
687
|
-
f"(+{_plural(ev['records'], 'record')})")
|
|
697
|
+
note = evidence_note(doc)
|
|
698
|
+
if note:
|
|
699
|
+
lines.append(f"{'Evidence':<{LABEL}}{note}")
|
|
688
700
|
lines.append(summary(doc))
|
|
689
701
|
return "\n".join(lines)
|
|
690
702
|
|
|
@@ -725,6 +737,17 @@ def summary(doc: dict) -> str:
|
|
|
725
737
|
return " · ".join(parts)
|
|
726
738
|
|
|
727
739
|
|
|
740
|
+
def evidence_note(doc: dict) -> str | None:
|
|
741
|
+
"""Where the evidence went: `<path> (+N records)`, `not written:
|
|
742
|
+
<reason>`, or None when there was nothing to write."""
|
|
743
|
+
ev = doc.get("evidence")
|
|
744
|
+
if ev and ev.get("not_written"):
|
|
745
|
+
return f"not written: {ev['not_written']}"
|
|
746
|
+
if ev:
|
|
747
|
+
return f"{ev['path']} (+{_plural(ev['records'], 'record')})"
|
|
748
|
+
return None
|
|
749
|
+
|
|
750
|
+
|
|
728
751
|
def receipt_lines(doc: dict) -> dict[str, list[str]]:
|
|
729
752
|
"""Texts the receipt places under its own labels."""
|
|
730
753
|
verified = [e["line"] for e in doc["datasets"] if e["line"]]
|
|
@@ -734,6 +757,7 @@ def receipt_lines(doc: dict) -> dict[str, list[str]]:
|
|
|
734
757
|
for f in failures(doc)],
|
|
735
758
|
"not_verified": not_verified_lines(doc),
|
|
736
759
|
"not_checked": not_checked_lines(doc, include_invalid=False),
|
|
760
|
+
"evidence": evidence_note(doc),
|
|
737
761
|
}
|
|
738
762
|
|
|
739
763
|
|
|
@@ -29,6 +29,7 @@ import time
|
|
|
29
29
|
from truequery import engine as E
|
|
30
30
|
from truequery import project as P
|
|
31
31
|
from truequery import report as RP
|
|
32
|
+
from truequery import safewrite
|
|
32
33
|
from truequery import settings as S
|
|
33
34
|
from truequery.analyzers import pandas_checks
|
|
34
35
|
from truequery.analyzers import sql as analyzer
|
|
@@ -325,19 +326,19 @@ def save_session(root: str, session: dict) -> None:
|
|
|
325
326
|
state never lands in the user's repo. ignores.json stays committable."""
|
|
326
327
|
state_dir = os.path.join(root, ".truequery")
|
|
327
328
|
try:
|
|
328
|
-
|
|
329
|
+
# Never through a link (safewrite.UnsafePathError is an OSError):
|
|
330
|
+
# skipped silently; dedup then degrades to "said again".
|
|
331
|
+
safewrite.makedirs(root, state_dir)
|
|
329
332
|
ignore = os.path.join(state_dir, ".gitignore")
|
|
330
|
-
if not os.path.
|
|
331
|
-
with
|
|
333
|
+
if not os.path.lexists(ignore):
|
|
334
|
+
with safewrite.open_text(root, ignore, "x") as handle:
|
|
332
335
|
handle.write("# TrueQuery session state (ignores.json is meant "
|
|
333
336
|
"to be committed)\nsession.json\nhook.log\n")
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
handle, indent=2, sort_keys=True)
|
|
340
|
-
os.replace(tmp, _session_path(root))
|
|
337
|
+
safewrite.replace_text(root, _session_path(root), json.dumps(
|
|
338
|
+
{"version": 2,
|
|
339
|
+
**{name: session.get(name, _fresh_session()[name])
|
|
340
|
+
for name in SESSION_FIELDS}},
|
|
341
|
+
indent=2, sort_keys=True))
|
|
341
342
|
except OSError:
|
|
342
343
|
pass
|
|
343
344
|
|
|
@@ -725,15 +726,26 @@ def _read_config(path: str) -> dict:
|
|
|
725
726
|
return data
|
|
726
727
|
|
|
727
728
|
|
|
728
|
-
def _write_config(path: str, data: dict) -> None:
|
|
729
|
+
def _write_config(path: str, data: dict, root: str | None = None) -> None:
|
|
730
|
+
"""`root` given (project scope): never through a link under it
|
|
731
|
+
(raises safewrite.UnsafePathError). Global scope writes the user's own
|
|
732
|
+
home config, which may well be a link they made (dotfiles)."""
|
|
733
|
+
text = json.dumps(data, indent=2) + "\n"
|
|
734
|
+
if root is not None:
|
|
735
|
+
safewrite.makedirs(root, os.path.dirname(path) or root)
|
|
736
|
+
safewrite.replace_text(root, path, text)
|
|
737
|
+
return
|
|
729
738
|
os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
|
|
730
739
|
tmp = f"{path}.{os.getpid()}.tmp"
|
|
731
740
|
with open(tmp, "w", encoding="utf-8") as handle:
|
|
732
|
-
|
|
733
|
-
handle.write("\n")
|
|
741
|
+
handle.write(text)
|
|
734
742
|
os.replace(tmp, path)
|
|
735
743
|
|
|
736
744
|
|
|
745
|
+
def _guard_root(args) -> str | None:
|
|
746
|
+
return None if args.scope == "global" else _scope_root(args)
|
|
747
|
+
|
|
748
|
+
|
|
737
749
|
def _our_commands(config: dict) -> list[str]:
|
|
738
750
|
return [h["command"] for groups in config.get("hooks", {}).values()
|
|
739
751
|
for g in groups if isinstance(g, dict)
|
|
@@ -794,8 +806,13 @@ def install(args) -> int:
|
|
|
794
806
|
"and run install again.", file=sys.stderr)
|
|
795
807
|
return 2
|
|
796
808
|
command = _hook_command(name)
|
|
797
|
-
|
|
798
|
-
|
|
809
|
+
try:
|
|
810
|
+
_write_config(path, _with_our_hooks(config, HARNESSES[name][1],
|
|
811
|
+
command), _guard_root(args))
|
|
812
|
+
except safewrite.UnsafePathError as exc:
|
|
813
|
+
print(f"truequery install: not written: {exc}. Nothing was "
|
|
814
|
+
"changed.", file=sys.stderr)
|
|
815
|
+
return 2
|
|
799
816
|
print(f"truequery install: wrote {path}")
|
|
800
817
|
print(f"truequery install: hook command is {command}")
|
|
801
818
|
print(f"truequery install: {HARNESSES[name][2]}")
|
|
@@ -881,7 +898,12 @@ def uninstall(args) -> int:
|
|
|
881
898
|
continue
|
|
882
899
|
count = _without_our_hooks(config) if config else 0
|
|
883
900
|
if count:
|
|
884
|
-
|
|
901
|
+
try:
|
|
902
|
+
_write_config(path, config, _guard_root(args))
|
|
903
|
+
except safewrite.UnsafePathError as exc:
|
|
904
|
+
print(f"truequery uninstall: skipped {path}: {exc}",
|
|
905
|
+
file=sys.stderr)
|
|
906
|
+
continue
|
|
885
907
|
removed += count
|
|
886
908
|
if _plugin_enabled(args):
|
|
887
909
|
print("truequery uninstall: the truequery plugin is enabled; its hooks are "
|
|
@@ -34,6 +34,7 @@ import yaml
|
|
|
34
34
|
|
|
35
35
|
from truequery import contract_v2 as C2
|
|
36
36
|
from truequery import project as P
|
|
37
|
+
from truequery import safewrite
|
|
37
38
|
|
|
38
39
|
SAMPLE_ROWS = 2_000 # rows read per dataset, at most
|
|
39
40
|
MAX_LINE_CHARS = 1_048_576 # one physical line, at most
|
|
@@ -1840,15 +1841,26 @@ def _finish(entry: dict, root: str, config: dict | None) -> str:
|
|
|
1840
1841
|
return text
|
|
1841
1842
|
|
|
1842
1843
|
|
|
1844
|
+
def targets(root: str, result: dict) -> list[str]:
|
|
1845
|
+
"""Every path `write` may create."""
|
|
1846
|
+
return [os.path.join(root, "contracts")] + [
|
|
1847
|
+
os.path.join(root, entry["file"]) for entry in result["drafts"]]
|
|
1848
|
+
|
|
1849
|
+
|
|
1843
1850
|
def write(root: str, result: dict) -> list[str]:
|
|
1844
1851
|
"""Write the drafts; never over an existing file."""
|
|
1845
1852
|
written = []
|
|
1846
1853
|
cdir = os.path.join(root, "contracts")
|
|
1847
|
-
|
|
1854
|
+
# Never through a link: every target is checked before any write
|
|
1855
|
+
# (raises safewrite.UnsafePathError).
|
|
1856
|
+
for path in targets(root, result):
|
|
1857
|
+
safewrite.check(root, path)
|
|
1858
|
+
safewrite.makedirs(root, cdir)
|
|
1848
1859
|
for entry in result["drafts"]:
|
|
1849
1860
|
dest = os.path.join(root, entry["file"])
|
|
1850
1861
|
try:
|
|
1851
|
-
with
|
|
1862
|
+
with safewrite.open_text(root, dest, "x",
|
|
1863
|
+
newline="\n") as handle:
|
|
1852
1864
|
handle.write(entry["text"])
|
|
1853
1865
|
except FileExistsError:
|
|
1854
1866
|
entry["skipped"] = True
|
|
@@ -17,6 +17,7 @@ from sqlglot import exp
|
|
|
17
17
|
from sqlglot.dialects.dialect import Dialect
|
|
18
18
|
|
|
19
19
|
from truequery import contract_v2
|
|
20
|
+
from truequery import safewrite
|
|
20
21
|
from truequery.analyzers import sql as analyzer
|
|
21
22
|
|
|
22
23
|
SKIP_DIRS = ("target", "dbt_packages", "node_modules", ".venv", ".git",
|
|
@@ -879,14 +880,33 @@ def _contract_for_spec(spec: dict, source: str) -> str:
|
|
|
879
880
|
return "\n".join(lines) + "\n"
|
|
880
881
|
|
|
881
882
|
|
|
882
|
-
def seed_contracts(root: str) -> list[str]:
|
|
883
|
+
def seed_contracts(root: str, plan: list | None = None) -> list[str]:
|
|
884
|
+
"""Write the contracts `seed_plan` found (`plan`, or a fresh one)."""
|
|
885
|
+
todo = seed_plan(root) if plan is None else plan
|
|
886
|
+
created: list[str] = []
|
|
887
|
+
# Never through a link: every target is checked before any write
|
|
888
|
+
# (raises safewrite.UnsafePathError).
|
|
889
|
+
safewrite.makedirs(root, os.path.join(root, "contracts"))
|
|
890
|
+
for dest, _spec, _source in todo:
|
|
891
|
+
safewrite.check(root, dest)
|
|
892
|
+
for dest, spec, source in todo:
|
|
893
|
+
with safewrite.open_text(root, dest, "x") as handle:
|
|
894
|
+
handle.write(_contract_for_spec(spec, source))
|
|
895
|
+
created.append(dest)
|
|
896
|
+
return created
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
def seed_plan(root: str, skipped: list | None = None
|
|
900
|
+
) -> list[tuple[str, dict, str]]:
|
|
883
901
|
"""Seed contracts/ from dbt schema YAML (models: - name: ...).
|
|
884
902
|
|
|
885
903
|
Grain/keys/allowed_values come from declared uniqueness and
|
|
886
904
|
accepted-values tests; everything else is an explicit TODO, never
|
|
887
|
-
invented. Existing contracts are always kept. Returns
|
|
905
|
+
invented. Existing contracts are always kept. Returns
|
|
906
|
+
[(target path, spec, source)] for `seed_contracts`. A model whose
|
|
907
|
+
name can't be a file name is left out, with (name, source, reason)
|
|
908
|
+
added to `skipped`.
|
|
888
909
|
"""
|
|
889
|
-
created: list[str] = []
|
|
890
910
|
specs: list[tuple[dict, str]] = []
|
|
891
911
|
for dirpath, dirnames, filenames in os.walk(root):
|
|
892
912
|
dirnames[:] = sorted(d for d in dirnames
|
|
@@ -904,19 +924,21 @@ def seed_contracts(root: str) -> list[str]:
|
|
|
904
924
|
except (OSError, ValueError, yaml.YAMLError):
|
|
905
925
|
continue
|
|
906
926
|
if isinstance(data, dict):
|
|
927
|
+
source = os.path.relpath(path, root).replace(os.sep, "/")
|
|
907
928
|
for spec in _dbt_models(data):
|
|
908
|
-
|
|
909
|
-
|
|
929
|
+
reason = safewrite.bad_name(spec["name"])
|
|
930
|
+
if reason:
|
|
931
|
+
if skipped is not None:
|
|
932
|
+
skipped.append((str(spec["name"]), source, reason))
|
|
933
|
+
continue
|
|
934
|
+
specs.append((spec, source))
|
|
910
935
|
cdir = os.path.join(root, "contracts")
|
|
911
|
-
os.
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
handle.write(_contract_for_spec(spec, source))
|
|
918
|
-
created.append(dest)
|
|
919
|
-
return created
|
|
936
|
+
todo = [(os.path.join(cdir, f"{spec['name']}.yaml"), spec, source)
|
|
937
|
+
for spec, source in sorted(specs, key=lambda s: str(s[0]["name"]))]
|
|
938
|
+
# Kept: a real file already there. A link there is refused below.
|
|
939
|
+
todo = [t for t in todo
|
|
940
|
+
if os.path.islink(t[0]) or not os.path.lexists(t[0])]
|
|
941
|
+
return todo
|
|
920
942
|
|
|
921
943
|
|
|
922
944
|
def is_contract_or_metric_path(path: str, root: str) -> bool:
|
|
@@ -460,6 +460,8 @@ def render_receipt(receipt: dict) -> str:
|
|
|
460
460
|
data_nc = [DATA_LIMIT]
|
|
461
461
|
for text in data_nc:
|
|
462
462
|
lines.append(f"{'Not checked':<13}{text}")
|
|
463
|
+
if data_lines.get("evidence"):
|
|
464
|
+
lines.append(f"{'Evidence':<13}{data_lines['evidence']}")
|
|
463
465
|
elif receipt.get("local_data"):
|
|
464
466
|
names = receipt["local_data"]
|
|
465
467
|
shown = ", ".join(names[:3]) + (f" and {len(names) - 3} more"
|