-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample_use_profiles_yml.py
More file actions
35 lines (27 loc) · 1.04 KB
/
example_use_profiles_yml.py
File metadata and controls
35 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Example showcasing how to use a profiles.yml file instead of a `ProfileMapping` with an Airflow connection.
"""
from cosmos import DbtDag, ProjectConfig, ProfileConfig, ExecutionConfig
import os
DBT_PROJECT_PATH = f"{os.environ['AIRFLOW_HOME']}/include/dbt/project_with_profiles_yml"
DBT_EXECUTABLE_PATH = f"{os.getenv('AIRFLOW_HOME')}/dbt_venv_postgres/bin/dbt"
_project_config = ProjectConfig(
dbt_project_path=DBT_PROJECT_PATH,
)
# profile config using a profiles.yml file located in the dbt project
_profile_config = ProfileConfig(
profile_name="default",
target_name="dev",
profiles_yml_filepath=DBT_PROJECT_PATH + "/profiles.yml",
)
# Only needed if you can't install dbt-postgres in the requirements.txt file
_execution_config = ExecutionConfig(
dbt_executable_path=DBT_EXECUTABLE_PATH,
)
example_use_profiles_yml = DbtDag(
dag_id="example_use_profiles_yml",
project_config=_project_config,
profile_config=_profile_config,
execution_config=_execution_config,
tags=["out-of-the-box", "profiles-yml"],
)