dbt-tidy is a Python package designed to review your dbt project and enforce validation checks for project structure and standards.
Project description
dbt-tidy
dbt-tidy
is a CLI tool written in Python and is designed to run sweeps
(checks) against the structure and quality of your dbt project. It ensures that your project adheres to best practices and consistency standards, helping maintain clean and efficient dbt codebases.
The sweeps
in this package are inspired by dbt-project-evaluator
and dbt-checkpoint
, but it sets itself apart by offering a more flexible and easily extendable framework for creating custom sweeps
.
Installation
Use the package manager pip to install dbt-tidy
.
pip install dbt-tidy
Usage
#Run all built-in and custom sweeps
dbt-tidy sweep
Sweeping...
Duplicate Sources
Status: pass
Direct Join to Source
Status: fail
Resolution: Read from the staging model instead of the source.
Nodes:
- model.your_package.node_one
- model.your_package.node_two
- model.your_package.node_three
- model.your_package.node_four
- model.your_package.node_five
...and 5 more
#Use the dbt_unique_ids argument to run sweeps against a subset of dbt objects
dbt-tidy sweep model.your_package.model_name test.your_package.test_name.abcde12345 seed.your_package.seed_name
#Use the --include options to run a subset of sweeps
dbt-tidy sweep --include root_models duplicate_sources
#Use the --output-failures to write failures to a JSON file.
dbt-tidy sweep --output-failures ./failures.json
#Use the --manifest-path to specify the location of your dbt manifest.
#If this is not specified, dbt-tidy will assume it is at: target/manifest.json
dbt-tidy sweep --manifest-path ./located/here/manifest.json
Configuration
You can configure the behavior of dbt-tidy
by creating a tidy.yaml
file in your project root. In this file, you can specify which sweeps to enable or exclude and set project-specific settings.
The location of tidy.yaml
can be overridden by setting the TIDY_CONFIG_PATH environment variable.
manifest_path: some/directory/manifest.json
#The directory where your custom sweeps are located.
custom_sweeps_path: .tidy
#Control the behavior of the `sweeps` list.
#`include`: Only run the specified sweeps.
#`exclude`: Run all sweeps, except those specified.
#`all`: Run all sweeps, regardless of what is defined in the sweeps list.
#NOTE: The --include cli option will always override what is specified in this file.
mode: include
sweeps:
- root_models
Writing Custom Sweeps
If you would like to create custom sweeps for your project, dbt-tidy
allows you to write and integrate them easily.
It is as easy as:
- Create a directory for your sweeps. By default,
dbt-tidy
will look for custom sweeps in./.tidy
, but you can override this in thetidy.yaml
file. - Create a
sweep
decorated function which returns a list of dbt unique ids.
The @sweep
decorator not only runs validation checks but also provides a fully parsed manifest of your dbt project, represented as a Pydantic model. This means you have direct access to the entire dbt manifest, including models, tests, and other configurations, in a structured and type-validated format. The power of this approach lies in how easily you can interact with and query the project metadata, enabling you to write more sophisticated custom sweeps
.
from tidy.sweeps.base import sweep
from tidy.manifest.utils.types import ManifestType
@sweep(
name="Friendly Name That Will Print in the CLI",
resolution="Optionally provide a brief explanation for how to correct failures.",
)
def no_ephemerals(manifest: ManifestType) -> list:
failures = []
for node in manifest.nodes.values():
if node.resource_type == "model" and node.config.materialized == "ephemeral":
failures.append(node.unique_id)
return failures
Then you can run this custom sweep
the same as any built-in sweep
.
#Run all built-in and custom sweeps
dbt-tidy sweep --include no_ephemerals
Sweeping...
Friendly Name That Will Print in the CLI
Status: pass
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
MIT License
Copyright (c) 2025 Cameron Cyr
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dbt_tidy-0.6.0.tar.gz
.
File metadata
- Download URL: dbt_tidy-0.6.0.tar.gz
- Upload date:
- Size: 36.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.11.9 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 957afbfbcb4b5d44e5406def463f79aa38977230e4a755e54fa34fe88f6e27d4 |
|
MD5 | 37bfb3dd547ec1ad26e6e734b48b4001 |
|
BLAKE2b-256 | 786c70818644334d13dd349f3ed454a76f1c32daa21cce32d32458ad8e6de127 |
File details
Details for the file dbt_tidy-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: dbt_tidy-0.6.0-py3-none-any.whl
- Upload date:
- Size: 126.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.11.9 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73c015d33fc34708ac2f3ca58419cb6d48b6141b9a6cbadaeebb958476d0beff |
|
MD5 | 3c1626ec45edb0fa62590ad429a8a5ac |
|
BLAKE2b-256 | 73b1067b4f0f3ffda7360d527dd7925e598c4fa033d7b21b7e9d0147a29e5f9d |