A Python package for generating dbt schema.yml files.
Project description
dbt-yamer
Overview
dbt-yamer is a Python wrapper designed to simplify and enhance the generation of YAML schema files for dbt projects. With a focus on faster schema YAML and doc block generation, dbt-yamer aids development and helps avoid documentation and contract technical debt. By leveraging this CLI tool built on the dbt context, developers can streamline the management of dbt models and associated metadata.
Key Features
- Automates YAML schema generation for dbt models.
- Integrates doc blocks directly into column descriptions.
- Supports fuzzy matching to map columns to the best documentation blocks.
- CLI tool for seamless usage.
Installation
Prerequisites
Ensure you have the following prerequisites:
- Python 3.8 or higher
- pip (Python package installer)
- dbt
- A working dbt project
Installing dbt-yamer
pip install dbt-yamer
Usage
Command Line Interface (CLI)
The primary interface for dbt-yamer is through the CLI.
Generate YAML Files
Generate YAML schema files for one or more dbt models using the dbt-yamer yaml -m or --models switch:
dbt-yamer yaml -m <model_name1> <model_name2>
Example
To generate YAML for a model named customer_data, run:
dbt-yamer yaml -m customer_data
This command will generate a YAML schema file for the customer_data model, including:
- Column definitions with descriptions.
- Automatically integrated doc blocks for relevant columns.
- Fuzzy-matched documentation for improved accuracy.
Usage Examples
With this updated code, your CLI command can be used as follows:
# By default, loads manifest from target/manifest.json
dbt-yamer yaml -m model_a model_b
# Specifying a custom manifest path
dbt-yamer yaml -m model_a --manifest path/to/another_manifest.json
# Specifying a custom target label (dbt's "target" as in --target <env>)
dbt-yamer yaml -m model_a -t uat
# A combination of manifest, target, and multiple models
dbt-yamer yaml -m model_a -m model_b --manifest path/to/another_manifest.json -t uat
# Generate just YAML
dbt-yamer yaml -m/--models model_name
# Generate just markdown
dbt-yamer md -m/--models model_name
# Generate both YAML and markdown
dbt-yamer yamd -m model_name
--manifestdefaults totarget/manifest.json.--target/-tdefaults to local environment, but also can be overridden (e.g.,-t uat).--models/-mrequires at least one model name, and you can pass in multiple.
Output
- YAML schema files are created in the same directory as their corresponding
.sqlfiles. - If a schema file already exists, new files are versioned with
_v1,_v2, etc. - Doc blocks are automatically added to column descriptions in the format:
description: "{{ doc('doc_block_name') }}"
Development and Contributing
Development Environment Setup
-
Clone the Repository
git clone <repository-url> cd dbt-yamer
-
Create and Activate a Virtual Environment
python3 -m venv env source env/bin/activate # On Windows: env\Scripts\activate
-
Install Development Dependencies
Instead of
pytest, the project uses Makefile commands for setup and testing. Use the following commands:To Clean and Restart the Environment:
make clean restart
This will clean up any existing environment and install the package along with its dependencies.
-
Run Makefile Commands
Use the provided Makefile for various tasks. For example:
make restart: Reinstalls the package.make clean: Removes temporary files and builds.
Contributing Guidelines
-
Feature Development:
-
Create a new branch for your feature or bug fix.
git checkout -b feature/your-feature-name
-
-
Adhere to Code Standards:
- Follow PEP 8 guidelines.
- Use type hints where applicable.
- Run
pylintto ensure code quality.
-
Submit a Pull Request:
-
Push your branch to the repository.
git push origin feature/your-feature-name
-
Open a pull request with a clear description of your changes.
-
Support
For issues and feature requests, please create an issue in the dbt-yamer GitHub repository.
Authors
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt_yamer-0.1.3.tar.gz.
File metadata
- Download URL: dbt_yamer-0.1.3.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac29216bf139ec4315e75eb98da54a17819d8990cc93a1b7d772d0e0ab4b5be8
|
|
| MD5 |
336ff0e06e27cbf126224603ae2073d6
|
|
| BLAKE2b-256 |
4b61ebf382244f870ee1892e2a8699be295525b8ef4bfde14cef8395b468d842
|
File details
Details for the file dbt_yamer-0.1.3-py3-none-any.whl.
File metadata
- Download URL: dbt_yamer-0.1.3-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
318323d1f51932d6cb520b6f71dfb6045092e1de933f5c9ab37a8a65191b5528
|
|
| MD5 |
e4d8dbbd5736f16a2ccaeda5d1bec595
|
|
| BLAKE2b-256 |
e0e1d810ef0d1a22ae083f4e860fb9dbc149e6e204f73de44487f5d4e76dfb1e
|