Skip to main content

Fabric notebook dbt job runner (clone + run + persist) on top of the official dbt-fabricspark adapter.

Project description

vdstudio-dbtfabric-notebook

A thin dbt job runner for Microsoft Fabric notebooks, built on top of the official dbt-fabricspark adapter.

A Fabric deploy notebook installs this package and makes a single call — run_dbt_job(config) — which clones the dbt project from Git, runs the dbt command(s), and persists logs and artifacts to the lakehouse.

Install

pip install vdstudio-dbtfabric-notebook

The Fabric notebook runtime must also have dbt-core and dbt-fabricspark available (the runner shells out to the dbt CLI). notebookutils is provided by the Fabric runtime and is imported lazily only when fetching GitHub App secrets from Key Vault.

Use

Inside a Fabric notebook:

from vdstudio_dbtfabric_notebook import (
    run_dbt_job,
    DbtJobConfig,
    RepoConfig,
    ConnectionConfig,
)

config = DbtJobConfig(
    command=["dbt deps", "dbt build --target prod"],
    repo=RepoConfig(
        url=repo_url,
        branch=repo_branch,
        github_app_id=github_app_id,            # Key Vault secret name
        github_installation_id=github_installation_id,  # Key Vault secret name
        github_pem_secret=github_pem_secret,    # Key Vault secret name
        vault_url=vault_url,
    ),
    connection=ConnectionConfig(
        lakehouse_name=lakehouse_name,
        lakehouse_id=lakehouse_id,
        workspace_id=workspace_id,
        workspace_name=workspace_name,
        schema_name=schema_name,
    ),
)

result = run_dbt_job(config)

What it does

run_dbt_job(config):

  1. Environment setup — sets LAKEHOUSE, LAKEHOUSE_ID, SCHEMA, WORKSPACE_ID, WORKSPACE_NAME, DBT_JOB_NAME so the cloned project's profiles.yml resolves via env_var().
  2. Clonegit clone --depth 1 -b <branch>, authenticated via a GitHub App. The app id, installation id, and PEM private key are Key Vault secret names, fetched at runtime through notebookutils. A pre-resolved token may be supplied to skip the GitHub App flow; public repos clone without auth.
  3. Rundbt deps, then the dbt command(s) in order. Logs are emitted as JSON; dbt.log, run_results.json, and manifest.json are persisted to /lakehouse/default/Files/logs/dbt/{YYYY}/{MM}/{DD}/{invocation_id}/.

Commands can be a single string or a list run sequentially; the returned DbtResult is from the last command.

Ephemeral validation

The runner consumes whatever ConnectionConfig and command it is given. A wrapper pipeline can override the lakehouse/workspace parameters and swap --target prod for an ephemeral target to validate against a throwaway lakehouse, without any code change in this package.

Security

GitHub App secrets and tokens are never baked into the notebook; the notebook passes Key Vault secret names, and the actual values are resolved at runtime inside the Fabric environment.

Development

pip install -e ".[dev]"
pytest

License

Apache-2.0

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

vdstudio_dbtfabric_notebook-0.1.0.tar.gz (48.9 kB view details)

Uploaded Source

Built Distribution

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

vdstudio_dbtfabric_notebook-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for vdstudio_dbtfabric_notebook-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b7909ceacabe64147bc471d352b92df8aeb9cad5793d7bc8ea4e18e739427a60
MD5 aee7b2a4527486f3d3da61bd5c661fa5
BLAKE2b-256 26fb369c1a444d0b52f8bb5ed3e2604a3d97a6700c10246ea8bc186765774450

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vdstudio_dbtfabric_notebook-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71d3c0d782c6540fb4d042dd91f7a001066ae0de1aee336846f6c4b947c7a313
MD5 a9d9bc7615f58a8f98e8a7c5ed81113e
BLAKE2b-256 844c173981b4b0c9e9bb3555e45ed94c67b108a67141d8f11f8a3877dfde375b

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