Skip to content

Commit 96edc3d

Browse files
committed
Fix dag in module 3
Signed-off-by: Danny Chiao <danny@tecton.ai>
1 parent 4e58c06 commit 96edc3d

1 file changed

Lines changed: 50 additions & 42 deletions

File tree

‎module_3/README.md‎

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -112,48 +112,56 @@ The example dag is going to run on a daily basis and materialize *all* feature v
112112
With dbt incremental models, the model itself in incremental mode selects overlapping windows of data to account for late arriving data. Feast materialization similarly has a late arriving threshold.
113113

114114
```python
115-
dbt_test = BashOperator(
116-
task_id="dbt_test",
117-
bash_command="""
118-
cd ${AIRFLOW_HOME}; dbt test --models "aggregate_transaction_features"
119-
""",
120-
dag=dag,
121-
)
122-
123-
dbt_run = BashOperator(
124-
task_id="dbt_run",
125-
bash_command="""
126-
cd ${AIRFLOW_HOME}; dbt run --models "aggregate_transaction_features"
127-
""",
128-
dag=dag,
129-
)
130-
131-
@task()
132-
def materialize(data_interval_start=None, data_interval_end=None):
133-
repo_config = RepoConfig(
134-
registry=RegistryConfig(
135-
registry_type="sql",
136-
path="postgresql://postgres:mysecretpassword@127.0.0.1:55001/feast",
137-
),
138-
project="feast_demo_local",
139-
provider="local",
140-
offline_store=SnowflakeOfflineStoreConfig(
141-
account=os.getenv("SNOWFLAKE_DEPLOYMENT_URL"),
142-
user=os.getenv("SNOWFLAKE_USER"),
143-
password=os.getenv("SNOWFLAKE_PASSWORD"),
144-
role=os.getenv("SNOWFLAKE_ROLE"),
145-
warehouse=os.getenv("SNOWFLAKE_WAREHOUSE"),
146-
database=os.getenv("SNOWFLAKE_DATABASE"),
147-
schema_=os.getenv("SNOWFLAKE_SCHEMA")
148-
),
149-
online_store=RedisOnlineStoreConfig(connection_string="localhost:6379"),
150-
entity_key_serialization_version=2
151-
)
152-
store = FeatureStore(config=repo_config)
153-
store.materialize(data_interval_start.subtract(hours=1), data_interval_end)
154-
155-
# Setup DAG
156-
dbt_test >> dbt_run >> materialize()
115+
with DAG(
116+
dag_id='feature_dag',
117+
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
118+
description='A dbt + Feast DAG',
119+
schedule="@daily",
120+
catchup=False,
121+
tags=["feast"],
122+
) as dag:
123+
dbt_test = BashOperator(
124+
task_id="dbt_test",
125+
bash_command="""
126+
cd ${AIRFLOW_HOME}; dbt test --models "aggregate_transaction_features"
127+
""",
128+
dag=dag,
129+
)
130+
131+
dbt_run = BashOperator(
132+
task_id="dbt_run",
133+
bash_command="""
134+
cd ${AIRFLOW_HOME}; dbt run --models "aggregate_transaction_features"
135+
""",
136+
dag=dag,
137+
)
138+
139+
@task()
140+
def materialize(data_interval_start=None, data_interval_end=None):
141+
repo_config = RepoConfig(
142+
registry=RegistryConfig(
143+
registry_type="sql",
144+
path="postgresql://postgres:mysecretpassword@127.0.0.1:55001/feast",
145+
),
146+
project="feast_demo_local",
147+
provider="local",
148+
offline_store=SnowflakeOfflineStoreConfig(
149+
account=os.getenv("SNOWFLAKE_DEPLOYMENT_URL"),
150+
user=os.getenv("SNOWFLAKE_USER"),
151+
password=os.getenv("SNOWFLAKE_PASSWORD"),
152+
role=os.getenv("SNOWFLAKE_ROLE"),
153+
warehouse=os.getenv("SNOWFLAKE_WAREHOUSE"),
154+
database=os.getenv("SNOWFLAKE_DATABASE"),
155+
schema_=os.getenv("SNOWFLAKE_SCHEMA")
156+
),
157+
online_store=RedisOnlineStoreConfig(connection_string="localhost:6379"),
158+
entity_key_serialization_version=2
159+
)
160+
store = FeatureStore(config=repo_config)
161+
store.materialize(data_interval_start.subtract(hours=1), data_interval_end)
162+
163+
# Setup DAG
164+
dbt_test >> dbt_run >> materialize()
157165
```
158166

159167
#### Q: What if different feature views have different freshness requirements?

0 commit comments

Comments
 (0)