Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate dag for recency tests #500

Merged
merged 10 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
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
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
Loading