Skip to main content

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
  • --manifest defaults to target/manifest.json.
  • --target/-t defaults to local environment, but also can be overridden (e.g., -t uat).
  • --models/-m requires at least one model name, and you can pass in multiple.

Output

  • YAML schema files are created in the same directory as their corresponding .sql files.
  • 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

  1. Clone the Repository

    git clone <repository-url>
    cd dbt-yamer
    
  2. Create and Activate a Virtual Environment

    python3 -m venv env
    source env/bin/activate  # On Windows: env\Scripts\activate
    
  3. 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.

  4. 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

  1. Feature Development:

    • Create a new branch for your feature or bug fix.

      git checkout -b feature/your-feature-name
      
  2. Adhere to Code Standards:

    • Follow PEP 8 guidelines.
    • Use type hints where applicable.
    • Run pylint to ensure code quality.
  3. 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


Download files

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

Source Distribution

dbt_yamer-0.1.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

dbt_yamer-0.1.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file dbt_yamer-0.1.1.tar.gz.

File metadata

  • Download URL: dbt_yamer-0.1.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for dbt_yamer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a868ae4e8dc32b1b5fdd3e9ce6c9572f078787650f11c55e536c48002b9f6f95
MD5 66c1f5823b6ae7c36d49e3165d95ddd7
BLAKE2b-256 cd413d7af6a9ae6e0d6ae433a02410a431c696c80a30c9abbeb0c8abe7d58642

See more details on using hashes here.

File details

Details for the file dbt_yamer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dbt_yamer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for dbt_yamer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 097bcb05e23f76cfa64fe00222654da3193c84bf43a7561819c8f71eb79f77ea
MD5 b5d19abe531ab251d94bb997daddefd1
BLAKE2b-256 31bf44bed1b9323c54368ff45df99816f98a5e92609c0e6230212734c2c1c8a7

See more details on using hashes here.

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