Skip to main content

CLI to autofix deprecations in dbt projects

Project description

dbt-autofix (previously dbt-cleanup)

This tool can help teams clean up their dbt projects so that it conforms with dbt configuration best practices and update deprecated config:

Deprecation Code in dbt Core Files Description
CustomKeyInObjectDeprecation (*) YAML files Move all models configs under config: in YAML files
CustomKeyInObjectDeprecation (*) YAML files Move all models extra config (not valid or custom) under meta: and meta under config:
DuplicateYAMLKeysDeprecation YAML files Remove duplicate keys in YAML files, keeping the second one to keep the same behaviour
UnexpectedJinjaBlockDeprecation SQL files Remove extra {% endmacro %} and {% endif %} that don't have corresponding opening statements
- dbt_project.yml Prefix all configs for modeles/tests etc... with a +
ConfigDataPathDeprecation dbt_project.yml Remove deprecated config for data path (now seed)
ConfigLogPathDeprecation dbt_project.yml Remove deprecated config for log path
ConfigSourcePathDeprecation dbt_project.yml Remove deprecated config for source path
ConfigTargetPathDeprecation dbt_project.yml Remove deprecated config for target path

(*) : those autofix rules are currently deactivated in main

Installation

To run it from the git repo directly, install uv and then

run the tool directly

uvx --from git+https://github.com/dbt-labs/dbt-autofix.git dbt-autofix --help

or install it so that it can be run with dbt-cleanup in the future

uv tool install --from git+https://github.com/dbt-labs/dbt-autofix.git dbt-autofix

Usage

  • dbt-autofix deprecations: refactor YAML and SQL files to fix some deprecations
    • add --path <mypath> to configure the path of the dbt project (defaults to .)
    • add --dry-run for running in dry run mode
    • add --json to get resulting data in a JSONL format

Each JSON object will have the following keys:

  • "mode": "applied" or "dry_run"
  • "file_path": the full path of the file modified. Each file will appear only once
  • "refactors": the list of refactoring rules applied

Calling deprecations without --dry-run should be safe if your dbt code is part of a git repo.

Please review the suggested changes to your dbt project before merging to main and make those changes go through your typical CI/CD process.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbt_autofix-0.1.0.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbt_autofix-0.1.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file dbt_autofix-0.1.0.tar.gz.

File metadata

  • Download URL: dbt_autofix-0.1.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dbt_autofix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d19a3d036598847feefbdcea42153c217c173ffb5d3faec66125a3744e4fbfbd
MD5 5bc4e4e347ed6f48cbc722c81d40352a
BLAKE2b-256 80767da727109106a3d4e2e5347ffa2b8b1bb57a682e7419f02c4875c617efd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbt_autofix-0.1.0.tar.gz:

Publisher: release.yml on dbt-labs/dbt-autofix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbt_autofix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dbt_autofix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dbt_autofix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aba5780e6e0ca4783826adcdb897034a7ea372184dfb2bb845f4726c8603ba0f
MD5 486045e434ef98de825169b828199d79
BLAKE2b-256 fce1cf34bcd2b4a24a7085c4d6c10c7acf09a9e45a37f0f2068bcaa6976ab373

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbt_autofix-0.1.0-py3-none-any.whl:

Publisher: release.yml on dbt-labs/dbt-autofix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page