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

Create dag for soroban pipelines #248

Merged
merged 16 commits into from
Feb 20, 2024
6 changes: 3 additions & 3 deletions airflow_variables_dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"partnership_assets__account_holders_activity_fact": false,
chowbao marked this conversation as resolved.
Show resolved Hide resolved
"partnership_assets__asset_activity_fact": false
},
"dbt_image_name": "stellar/stellar-dbt:bbe7478",
"dbt_image_name": "chowbao/stellar-dbt:test37",
chowbao marked this conversation as resolved.
Show resolved Hide resolved
"dbt_job_execution_timeout_seconds": 300,
"dbt_job_retries": 1,
"dbt_mart_dataset": "test_sdf_marts",
Expand All @@ -132,7 +132,7 @@
"dbt_threads": 12,
"gcs_exported_data_bucket_name": "us-central1-hubble-1pt5-dev-7db0e004-bucket",
"gcs_exported_object_prefix": "dag-exported",
"image_name": "stellar/stellar-etl:3761e4a",
"image_name": "stellar/stellar-etl:1ba69a5",
"image_output_path": "/etl/exported_data/",
"image_pull_policy": "IfNotPresent",
"kube_config_location": "",
Expand Down Expand Up @@ -338,7 +338,7 @@
},
"currency_bucket": "currencies_ohlc",
"max_db_entry_age_in_days": 90,
"public_dbt_image_name": "stellar/stellar-dbt:bbe7478",
"public_dbt_image_name": "chowbao/stellar-dbt:test37",
"internal_source_db": "test-hubble-319619",
"internal_source_schema": "test_crypto_stellar_internal",
"public_source_db": "test-hubble-319619",
Expand Down
6 changes: 3 additions & 3 deletions airflow_variables_prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"dbt_threads": 12,
"gcs_exported_data_bucket_name": "us-central1-hubble-2-d948d67b-bucket",
"gcs_exported_object_prefix": "dag-exported",
"image_name": "stellar/stellar-etl:3761e4a",
"image_name": "stellar/stellar-etl:1ba69a5",
"image_output_path": "/etl/exported_data/",
"image_pull_policy": "IfNotPresent",
"kube_config_location": "",
Expand Down Expand Up @@ -361,6 +361,6 @@
"public_dbt_image_name": "stellar/stellar-dbt:bbe7478",
"internal_source_db": "hubble-261722",
"internal_source_schema": "crypto_stellar_internal_2",
"public_source_db": "crypto_stellar",
"public_source_schema": "crypto-stellar"
"public_source_db": "crypto-stellar",
"public_source_schema": "crypto_stellar"
}
4 changes: 3 additions & 1 deletion dags/dbt_sdf_marts_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
default_args=get_default_dag_args(),
start_date=datetime(2024, 1, 26, 0, 0),
description="This DAG runs dbt models at a daily cadence",
schedule_interval="0 13 * * *", # Runs at 13:00 UTC
schedule_interval="0 16 * * *", # Runs at 16:00 UTC
user_defined_filters={
"container_resources": lambda s: k8s.V1ResourceRequirements(requests=s),
},
Expand Down Expand Up @@ -41,6 +41,7 @@
network_stats_agg_task = dbt_task(dag, tag="network_stats")
partnership_assets_task = dbt_task(dag, tag="partnership_assets")
history_assets = dbt_task(dag, tag="history_assets")
soroban = dbt_task(dag, tag="soroban")

# DAG task graph
wait_on_dbt_enriched_base_tables >> ohlc_task >> liquidity_pool_trade_volume_task
Expand All @@ -55,3 +56,4 @@
wait_on_dbt_enriched_base_tables >> network_stats_agg_task
wait_on_dbt_enriched_base_tables >> partnership_assets_task
wait_on_dbt_enriched_base_tables >> history_assets
wait_on_dbt_enriched_base_tables >> soroban
2 changes: 1 addition & 1 deletion dags/partner_pipeline_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
default_args=get_default_dag_args(),
start_date=datetime(2023, 1, 1, 0, 0),
description="This DAG automates daily updates to partner tables in BigQuery.",
schedule_interval="0 13 * * *",
schedule_interval="0 16 * * *",
params={
"alias": "partner",
},
Expand Down
116 changes: 116 additions & 0 deletions dags/soroban_tables_dag.py
chowbao marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import datetime

from airflow import DAG
from airflow.models.variable import Variable
from stellar_etl_airflow.build_cross_dependency_task import build_cross_deps
from stellar_etl_airflow.build_dbt_task import build_dbt_task
from stellar_etl_airflow.default import get_default_dag_args, init_sentry

init_sentry()

dag = DAG(
"soroban_tables",
default_args=get_default_dag_args(),
start_date=datetime.datetime(2023, 9, 30),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will need to be whatever date the protocol upgrade for mainnet ends up being

description="This DAG runs dbt to create the tables for the models in marts/soroban.",
schedule_interval="0 17 * * *", # Daily 11 AM UTC
params={},
catchup=True,
max_active_runs=1,
)

# tasks for staging tables
stg_config_settings = build_dbt_task(dag, "stg_config_settings")
stg_contract_code = build_dbt_task(dag, "stg_contract_code")
stg_contract_data = build_dbt_task(dag, "stg_contract_data")
stg_ttl = build_dbt_task(dag, "stg_ttl")

# tasks for intermediate soroban aggregate tables
int_soroban__enriched_history_operations_year = build_dbt_task(
dag, "int_soroban__enriched_history_operations_year"
)

int_soroban__contract_metrics_day = build_dbt_task(
dag, "int_soroban__contract_metrics_day"
)
int_soroban__contract_metrics_day = build_dbt_task(
dag, "int_soroban__contract_metrics_week"
)
int_soroban__contract_metrics_day = build_dbt_task(
dag, "int_soroban__contract_metrics_month"
)
int_soroban__contract_metrics_day = build_dbt_task(
dag, "int_soroban__contract_metrics_year"
)

int_soroban__top_contract_activity_day = build_dbt_task(
dag, "int_soroban__top_contract_activity_day"
)
int_soroban__top_contract_activity_week = build_dbt_task(
dag, "int_soroban__top_contract_activity_week"
)
int_soroban__top_contract_activity_month = build_dbt_task(
dag, "int_soroban__top_contract_activity_month"
)
int_soroban__top_contract_activity_year = build_dbt_task(
dag, "int_soroban__top_contract_activity_year"
)

# tasks for marts tables
contract_assets_fact = build_dbt_task(dag, "contract_assets_fact")
contract_type_fact = build_dbt_task(dag, "contract_type_fact")
ttl_current = build_dbt_task(dag, "ttl_current")
soroban__contract_metrics_agg = build_dbt_task(dag, "soroban__contract_metrics_agg")
soroban__top_contract_activity_agg = build_dbt_task(
dag, "soroban__top_contract_activity_agg"
)

# DAG task graph
stg_config_settings
stg_contract_code

stg_contract_data >> contract_assets_fact
contract_type_fact
sydneynotthecity marked this conversation as resolved.
Show resolved Hide resolved
stg_ttl >> ttl_current

(
int_soroban__enriched_history_operations_year
>> int_soroban__contract_metrics_day
>> soroban__contract_metrics_agg
)
(
int_soroban__enriched_history_operations_year
>> int_soroban__contract_metrics_day
>> soroban__contract_metrics_agg
)
(
int_soroban__enriched_history_operations_year
>> int_soroban__contract_metrics_day
>> soroban__contract_metrics_agg
)
(
int_soroban__enriched_history_operations_year
>> int_soroban__contract_metrics_day
>> soroban__contract_metrics_agg
)

(
int_soroban__enriched_history_operations_year
>> int_soroban__top_contract_activity_day
>> soroban__top_contract_activity_agg
)
(
int_soroban__enriched_history_operations_year
>> int_soroban__top_contract_activity_week
>> soroban__top_contract_activity_agg
)
(
int_soroban__enriched_history_operations_year
>> int_soroban__top_contract_activity_month
>> soroban__top_contract_activity_agg
)
(
int_soroban__enriched_history_operations_year
>> int_soroban__top_contract_activity_year
>> soroban__top_contract_activity_agg
)
Loading