Skip to main content

flyteplugins-dbt

Run dbt CLI invocations as Flyte v2 tasks.

DbtTask maps one dbtRunner.invoke(...) call to one Flyte task. Project-level dbt paths are configured on the task, and invocation-level options are task inputs.

Install the dbt adapter required by your project, such as dbt-duckdb, dbt-bigquery, or dbt-snowflake, in the task image alongside this plugin.

from pathlib import Path

import flyte
from flyteplugins.dbt import DbtTask

DBT_PROJECT_DIR = "jaffle_shop"
DBT_PROFILES_DIR = "dbt-profiles"

env = flyte.TaskEnvironment(
    name="dbt",
    image=flyte.Image.from_debian_base()
    .with_requirements("requirements.txt")
    .with_source_folder(Path(DBT_PROJECT_DIR))
    .with_source_folder(Path(DBT_PROFILES_DIR)),
)

dbt_test = DbtTask(
    name="dbt-test",
    task_environment=env,
    project_dir=DBT_PROJECT_DIR,
    profiles_dir=DBT_PROFILES_DIR,
    profile=DBT_PROJECT_DIR,
    report=True,
)


@env.task
async def main():
    return await dbt_test.aio(command="test", select=["stg_orders+"], target="prod")

Multi-token dbt commands can be passed as a shell-style string or as explicit tokens:

await dbt_test.aio(command="docs generate")
await dbt_test.aio(command=["source", "freshness"])

The task returns a list of DbtNodeResult values summarized from dbt node results. If dbt reports failure, the task raises the dbt exception when one is available, otherwise it raises DbtInvocationError with the summarized node results.

When report=True, the task writes a dbt report tab with node names, resource types, statuses, failures, execution times, and messages. The report is written before dbt failures are raised, so failed dbt runs can still show succeeded and failed node results.

Event callbacks

Custom dbt event callbacks can be passed to DbtTask.

def log_dbt_node(event):
    data = getattr(event, "data", None)
    node_info = getattr(data, "node_info", None)
    if node_info is None:
        return

    node_name = getattr(node_info, "node_name", None)
    node_status = getattr(node_info, "node_status", None)
    print(f"dbt node={node_name} status={node_status}")


dbt_test = DbtTask(
    name="dbt-test",
    task_environment=env,
    callbacks=[log_dbt_node],
)

For remote execution, callbacks must be importable functions. Import-path strings are also supported:

dbt_test = DbtTask(
    name="dbt-test",
    task_environment=env,
    callbacks=["my_project.callbacks.log_dbt_node"],
)

Metadata

Release files for flyteplugins-dbt 2.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for flyteplugins-dbt 2.12.0
File Interpreter ABI Platform Actions
flyteplugins_dbt-2.12.0-py3-none-any.whl Python 3 none any Details for flyteplugins_dbt-2.12.0-py3-none-any.whl

Release files / flyteplugins_dbt-2.12.0-py3-none-any.whl

Download URL flyteplugins_dbt-2.12.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5375ea8a11a4ab195360cf6dd05db571fe034c9c5270c271d184db8c4adf9a5
BLAKE2b-256 checksum
How to use checksums
14c8071c6e6521833c24d91afdcd3b79d5745a67b017e9469f0a4173a0239345
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for flyteplugins-dbt 2.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page