common_dagster.dbt
Container-owned dbt projects as one Dagster asset graph.
This optional surface deliberately lives behind common-dagster[dbt]. Importing
common_dagster for an ingestion-only container does not import dagster-dbt or
dbt Core. A dbt container opts in explicitly::
from common_dagster.dbt import DbtFlow, DbtReadiness, DbtWorkloadModels remain SQL-owned. These declarations own only the reusable Python bridge: stable asset keys, selected jobs, execution modes, and born-stopped readiness sensors.
Classes
ContainerDbtTranslator
Bases: DagsterDbtTranslator
Keep raw source keys canonical and namespace dbt-owned outputs.
__init__
def __init__(container: str) -> NoneFields and properties declared here; inherited members belong to the bases above.
container
container = containerget_asset_key
def get_asset_key(dbt_resource_props: Mapping[str, Any]) -> dg.AssetKeyget_group_name
def get_group_name(dbt_resource_props: Mapping[str, Any]) -> str | NoneDbtFlow
Build one container-local dbt project into Dagster Definitions.
There is exactly one @dbt_assets definition. Workloads crop it with
dbt selection syntax; execution mode is conveyed through stable run tags.
build adds --full-refresh. repair accepts a JSON-object
dbt/vars tag carrying explicit IDs/dates/partitions to the same SQL.
__init__
def __init__(*, project_dir: str | Path, container: str, workloads: Sequence[DbtWorkload], readiness: Sequence[DbtReadiness] = (), readiness_probe: ReadinessProbe | None = None, run_status_handler: RunStatusHandler | None = None, execution_gate: ExecutionGate | None = None, packaged_project_dir: str | Path | None = None, profiles_dir: str | Path | None = None, target: str | None = None, dbt_executable: str | Path | None = None, manifest: Mapping[str, Any] | str | Path | None = None) -> NoneFields and properties declared here; inherited members belong to the bases above.
container
container = containerdbt_executable
dbt_executable = Path(dbt_executable or shutil.which('dbt') or Path(sys.executable).with_name('dbt')).resolve()execution_gate
execution_gate = execution_gatemanifest
manifest = manifest if manifest is not None else self.project.manifest_pathproject
project = DbtProject(project_dir=(self.project_dir), profiles_dir=profiles_dir, target=target, packaged_project_dir=packaged_project_dir)project_dir
project_dir = Path(project_dir).resolve()readiness
readiness = tuple(readiness)readiness_probe
readiness_probe = readiness_proberun_status_handler
run_status_handler = run_status_handlerworkloads
workloads = tuple(workloads)definitions
def definitions() -> dg.DefinitionsResolve the project graph, selected jobs, and readiness sensors.
DbtReadiness
A target-aware, born-stopped sensor declaration for a dbt workload.
required_products are canonical raw product names, not operation step
names. The container-supplied probe owns target-specific state reads and
returns a Dagster RunRequest or SkipReason. Keeping that policy in
the container prevents this package from inventing a universal business
clock for markets, crypto, filings, and native metric partitions.
__init__
def __init__(name: str, job: str, required_products: tuple[str, ...], minimum_interval_seconds: int = 60, dirty_from_target: bool = False) -> NoneFields and properties declared here; inherited members belong to the bases above.
dirty_from_target
dirty_from_target: bool = Falsejob
job: strminimum_interval_seconds
minimum_interval_seconds: int = 60name
name: strrequired_products
required_products: tuple[str, ...]asset_keys
def asset_keys(container: str) -> tuple[dg.AssetKey, ...]Canonical raw or explicitly qualified derived keys in the barrier.
Bare names are canonical raw products. Slash-qualified names are full Dagster keys, which lets a downstream dbt workload wait on prior dbt products without inventing a second sensor abstraction.
DbtWorkload
One named Dagster job selecting part of one dbt asset graph.
__init__
def __init__(name: str, select: str, mode: DbtMode = 'update', description: str = '', exclude: str | None = None, tags: Mapping[str, str] = dict()) -> NoneFields and properties declared here; inherited members belong to the bases above.
description
description: str = ''exclude
exclude: str | None = Nonemode
mode: DbtMode = 'update'name
name: strselect
select: strtags
tags: Mapping[str, str] = field(default_factory=dict)Types and values
DbtMode
DbtMode = Literal['update', 'build', 'repair']ExecutionGate
ExecutionGate = Callable[[dg.AssetExecutionContext, str], Any]ReadinessProbe
ReadinessProbe = Callable[[dg.SensorEvaluationContext, 'DbtReadiness'], Any]RunStatusHandler
RunStatusHandler = Callable[[dg.RunStatusSensorContext, Literal['started', 'success', 'failed', 'canceled']], Any]