Initial demonstration of Snowflake as an offline+online store with Feast, using the Snowflake demo template.
In the steps below, we will set up a sample Feast project that leverages Snowflake as an offline store + materialization engine + online store.
Starting with data in a Snowflake table, we will register that table to the feature store and define features associated with the columns in that table. From there, we will generate historical training data based on those feature definitions and then materialize the latest feature values into the online store. Lastly, we will retrieve the materialized feature values.
Our template will generate new data containing driver statistics. From there, we will show you code snippets that will call to the offline store for generating training datasets, and then the code for calling the online store to serve you the latest feature values to serve models in production.
The following files will automatically be created in your project folder:
feature_store.yaml -- This is your main configuration file
driver_repo.py -- This is your main feature definition file
test.py -- This is a file to test your feature store configuration
Inspect feature_store.yaml
Here you will see the information that you entered. This template will use Snowflake as the offline store, materialization engine, and the online store. The main thing to remember is by default, Snowflake objects have ALL CAPS names unless lower case was specified.
feature_store.yaml
project:...registry:...provider:localoffline_store:type:snowflake.offlineaccount:SNOWFLAKE_DEPLOYMENT_URL#drop .snowflakecomputing.comuser:USERNAMEpassword:PASSWORDrole:ROLE_NAME#case sensitivewarehouse:WAREHOUSE_NAME#case sensitivedatabase:DATABASE_NAME#case cap sensitivebatch_engine:type:snowflake.engineaccount:SNOWFLAKE_DEPLOYMENT_URL#drop .snowflakecomputing.comuser:USERNAMEpassword:PASSWORDrole:ROLE_NAME#case sensitivewarehouse:WAREHOUSE_NAME#case sensitivedatabase:DATABASE_NAME#case cap sensitiveonline_store:type:snowflake.onlineaccount:SNOWFLAKE_DEPLOYMENT_URL#drop .snowflakecomputing.comuser:USERNAMEpassword:PASSWORDrole:ROLE_NAME#case sensitivewarehouse:WAREHOUSE_NAME#case sensitivedatabase:DATABASE_NAME#case cap sensitive
Run our test python script test.py
pythontest.py
What we did in test.py
Initialize our Feature Store
test.py
from datetime import datetime, timedeltaimport pandas as pdfrom driver_repo import driver, driver_stats_fvfrom feast import FeatureStorefs =FeatureStore(repo_path=".")fs.apply([driver, driver_stats_fv])
Create a dummy training dataframe, then call our offline store to add additional columns