Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 28 additions & 30 deletions orchestrate/dags/daily_loan_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@
from fivetran_provider_async.sensors import FivetranSensor
from airflow.providers.airbyte.operators.airbyte import AirbyteTriggerSyncOperator

@dag(
doc_md = __doc__,
catchup = False,

default_args = datacoves_utils.set_default_args(
owner = "Noel Gomez",
owner_email = "[email protected]"
@dag(
doc_md=__doc__,
catchup=False,
default_args=datacoves_utils.set_default_args(
owner="Noel Gomez", owner_email="[email protected]"
),

description = "Sample DAG to synchronize the Airflow database",
schedule = datacoves_utils.set_schedule("0 0 1 */12 *"),
tags=["extract_and_load", "transform", "marketing_automation", "update_catalog"],
description="Sample DAG to synchronize the Airflow database",
schedule=datacoves_utils.set_schedule("0 0 1 */12 *"),
tags=[
"extract_and_load",
"transform",
"marketing_automation",
"update_catalog",
"run_ci",
],
)
def daily_loan_run():

@task_group(
group_id="extract_and_load_airbyte",
tooltip="Airbyte Extract and Load"
)
@task_group(group_id="extract_and_load_airbyte", tooltip="Airbyte Extract and Load")
def extract_and_load_airbyte():
# Extact and load
sync_airbyte = AirbyteTriggerSyncOperator(
Expand All @@ -37,13 +38,11 @@ def extract_and_load_airbyte():
airbyte_conn_id="airbyte_connection",
)


@task_group(
group_id="extract_and_load_fivetran",
tooltip="Fivetran Extract and Load"
group_id="extract_and_load_fivetran", tooltip="Fivetran Extract and Load"
)
def extract_and_load_fivetran():
trigger_fivetran = FivetranOperator(
trigger_fivetran = FivetranOperator(
task_id="datacoves_snowflake_google_analytics_4_trigger",
fivetran_conn_id="fivetran_connection",
connector_id="speak_menial",
Expand All @@ -57,32 +56,26 @@ def extract_and_load_fivetran():
)
trigger_fivetran >> sensor_fivetran


@task_group(
group_id="extract_and_load_dlt",
tooltip="dlt Extract and Load"
)
@task_group(group_id="extract_and_load_dlt", tooltip="dlt Extract and Load")
def extract_and_load_dlt():
@task.datacoves_bash
def load_loans_data():
from orchestrate.utils import datacoves_utils

env_vars = datacoves_utils.set_dlt_env_vars({"destinations": ["main_load_keypair"]})
env_vars = datacoves_utils.set_dlt_env_vars(
{"destinations": ["main_load_keypair"]}
)
env_exports = datacoves_utils.generate_env_exports(env_vars)

return f"{env_exports}; cd load/dlt && ./loans_data.py"

load_loans_data()


# Transform Data
@task.datacoves_dbt(
connection_id="main_key_pair"
)
@task.datacoves_dbt(connection_id="main_key_pair")
def transform():
return "dbt build -s 'tag:daily_run_airbyte+ tag:daily_run_fivetran+'"


# Post transformation tasks
@task.datacoves_bash
def marketing_automation():
Expand All @@ -92,7 +85,12 @@ def marketing_automation():
def update_catalog():
return "echo 'refresh data catalog'"

extract_and_load = [extract_and_load_airbyte(), extract_and_load_fivetran(), extract_and_load_dlt()]
extract_and_load = [
extract_and_load_airbyte(),
extract_and_load_fivetran(),
extract_and_load_dlt(),
]
extract_and_load >> transform() >> [marketing_automation(), update_catalog()]


daily_loan_run()
Loading