Skip to content

Commit

Permalink
Add integration test for source node rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajastro committed Nov 15, 2024
1 parent 8ec46d2 commit a8d3dd2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions dev/dags/example_source_redering.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
An example DAG that uses Cosmos to render a dbt project into an Airflow DAG using Cosmos source rendering.
"""

import os
from datetime import datetime
from pathlib import Path

from cosmos import DbtDag, ProfileConfig, ProjectConfig, RenderConfig
from cosmos.constants import SourceRenderingBehavior
from cosmos.profiles import PostgresUserPasswordProfileMapping

DEFAULT_DBT_ROOT_PATH = Path(__file__).parent / "dbt"
DBT_ROOT_PATH = Path(os.getenv("DBT_ROOT_PATH", DEFAULT_DBT_ROOT_PATH))

profile_config = ProfileConfig(
profile_name="default",
target_name="dev",
profile_mapping=PostgresUserPasswordProfileMapping(
conn_id="example_conn",
profile_args={"schema": "public"},
disable_event_tracking=True,
),
)

source_rendering_dag = DbtDag(
# dbt/cosmos-specific parameters
project_config=ProjectConfig(
DBT_ROOT_PATH / "jaffle_shop",
),
profile_config=profile_config,
operator_args={
"install_deps": True, # install any necessary dependencies before running any dbt command
"full_refresh": True, # used only in dbt commands that support this flag
},
render_config=RenderConfig(source_rendering_behavior=SourceRenderingBehavior.ALL),
# normal dag parameters
schedule_interval="@daily",
start_date=datetime(2024, 1, 1),
catchup=False,
dag_id="source_rendering_dag",
default_args={"retries": 2},
)
2 changes: 2 additions & 0 deletions tests/test_example_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def get_dag_bag() -> DagBag:
file.writelines(["example_cosmos_sources.py\n"])
if DBT_VERSION < Version("1.6.0"):
file.writelines(["example_model_version.py\n"])
if DBT_VERSION < Version("1.5.0"):
file.writelines(["example_source_rendering.py\n"])

print(".airflowignore contents: ")
print(AIRFLOW_IGNORE_FILE.read_text())
Expand Down

0 comments on commit a8d3dd2

Please sign in to comment.