Skip to content

Commit

Permalink
Add separate dag for recency tests (#500)
Browse files Browse the repository at this point in the history
* Add dag for recency tests

* export env variable

* Update dbt image and schedule of recency dag

* update variables

* update dev image

* update the schedule

* lint

* Update dags/dbt_recency_tests_dag.py

Co-authored-by: chowbao <[email protected]>

* update dbt image

* update dag start date

---------

Co-authored-by: chowbao <[email protected]>
  • Loading branch information
amishas157 and chowbao authored Sep 25, 2024
1 parent 464bc76 commit 5f7ad2a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
3 changes: 2 additions & 1 deletion airflow_variables_dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"partnership_assets__account_holders_activity_fact": false,
"partnership_assets__asset_activity_fact": false
},
"dbt_image_name": "stellar/stellar-dbt:02123b970",
"dbt_image_name": "stellar/stellar-dbt:90c8a57c1",
"dbt_internal_source_db": "test-hubble-319619",
"dbt_internal_source_schema": "test_crypto_stellar_internal",
"dbt_job_execution_timeout_seconds": 300,
Expand Down Expand Up @@ -356,6 +356,7 @@
"network_stats": 720,
"ohlc": 720,
"partnership_assets": 660,
"recency": 600,
"relevant_asset_trades": 1200,
"singular_test": 600,
"snapshot_state": 600,
Expand Down
3 changes: 2 additions & 1 deletion airflow_variables_prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"partnership_assets__asset_activity_fact": false,
"trade_agg": false
},
"dbt_image_name": "stellar/stellar-dbt:02123b970",
"dbt_image_name": "stellar/stellar-dbt:90c8a57c1",
"dbt_internal_source_db": "hubble-261722",
"dbt_internal_source_schema": "crypto_stellar_internal_2",
"dbt_job_execution_timeout_seconds": 2400,
Expand Down Expand Up @@ -354,6 +354,7 @@
"network_stats": 360,
"ohlc": 960,
"partnership_assets": 1380,
"recency": 840,
"relevant_asset_trades": 1800,
"singular_test": 840,
"snapshot_state": 840,
Expand Down
40 changes: 40 additions & 0 deletions dags/dbt_recency_tests_dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from datetime import datetime

from airflow import DAG
from airflow.operators.empty import EmptyOperator
from kubernetes.client import models as k8s
from stellar_etl_airflow.build_dbt_task import dbt_task
from stellar_etl_airflow.build_elementary_slack_alert_task import elementary_task
from stellar_etl_airflow.default import (
alert_sla_miss,
get_default_dag_args,
init_sentry,
)

init_sentry()

with DAG(
"dbt_recency_tests",
default_args=get_default_dag_args(),
start_date=datetime(2024, 9, 24, 0, 0),
description="This DAG runs recency tests at a daily cadence",
schedule="0 20 * * *", # Every day at 8:00 PM UTC / 3:00 PM CST
user_defined_filters={
"container_resources": lambda s: k8s.V1ResourceRequirements(requests=s),
},
max_active_runs=1,
catchup=False,
tags=["dbt-data-quality"],
# sla_miss_callback=alert_sla_miss,
) as dag:

# DBT tests to run
recency_tests = dbt_task(
dag,
command_type="test",
tag="recency",
resource_cfg="dbt",
run_recency_test="true",
)

recency_tests
2 changes: 2 additions & 0 deletions dags/stellar_etl_airflow/build_dbt_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def dbt_task(
excluded=None,
resource_cfg="default",
run_singular_test="false",
run_recency_test="false",
):
namespace = conf.get("kubernetes", "NAMESPACE")
if namespace == "default":
Expand Down Expand Up @@ -136,6 +137,7 @@ def dbt_task(
"EXECUTION_DATE": "{{ ts }}",
"AIRFLOW_START_TIMESTAMP": "{{ ti.start_date.strftime('%Y-%m-%dT%H:%M:%SZ') }}",
"IS_SINGULAR_AIRFLOW_TASK": run_singular_test,
"IS_RECENCY_AIRFLOW_TASK": run_recency_test,
},
image=dbt_image,
arguments=args,
Expand Down

0 comments on commit 5f7ad2a

Please sign in to comment.