feat: initial project setup
This commit is contained in:
3
data_platform/__init__.py
Normal file
3
data_platform/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from data_platform.definitions import defs
|
||||
|
||||
__all__ = ["defs"]
|
||||
36
data_platform/definitions.py
Normal file
36
data_platform/definitions.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from pathlib import Path
|
||||
|
||||
from dagster import Definitions
|
||||
from dagster_dbt import DbtCliResource, DbtProject, dbt_assets
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# dbt project
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
DBT_PROJECT_DIR = Path(__file__).parent.parent / "dbt"
|
||||
|
||||
dbt_project = DbtProject(project_dir=str(DBT_PROJECT_DIR))
|
||||
|
||||
# When running locally outside Docker, generate/refresh the manifest automatically.
|
||||
dbt_project.prepare_if_dev()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# dbt assets – every dbt model/test/snapshot becomes a Dagster asset
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@dbt_assets(manifest=dbt_project.manifest_path)
|
||||
def dbt_project_assets(context, dbt: DbtCliResource):
|
||||
yield from dbt.cli(["build"], context=context).stream()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Definitions
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
defs = Definitions(
|
||||
assets=[dbt_project_assets],
|
||||
resources={
|
||||
"dbt": DbtCliResource(project_dir=str(DBT_PROJECT_DIR)),
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user