@@ -14,63 +14,42 @@ The _interoperable_ design of feast means that many Azure services can be used t
1414
1515## 🐱👤 Getting Started
1616
17- ### 1. Install Feast Azure Provider
17+ ### Pre-requisites
18+
19+ You will need to have:
1820
19- Git clone this repo and then:
21+ - An Azure account with an active subscription.
22+ - Don't have an Account? [ You can create an Azure account with $200 free credit] ( https://azure.microsoft.com/free/ ) .
23+ - Either an Azure SQL DB or Synapse SQL
24+ - A provisioned Azure Cache for Redis
25+ - An Azure Storage Account
26+
27+ ### 1. Install Feast Azure Provider
28+ Install the provider using ` pip ` (we recommend using either conda or virtualenv for environment isolation):
2029
2130``` bash
22- cd provider/sdk
23- pip install code/.
31+ pip install feast-azure-provider
2432```
2533
26- ** Note: Best practice is to use environment isolation (for example: virtualenv or conda) when installing**
34+ > ** Note**
35+ There is a dependency on the ` unixodbc ` operating system package. You can install this on Debian/Ubuntu using ` sudo apt-get install unixodbc-dev `
2736
28- ### 2. Connect to your feature store
37+ ### 2. Create a feature repository
2938
30- To connect to your feature store, you can use either:
31-
32- - Feast Python SDK, or
33- - Feast CLI
34-
35- #### a.) Using the Feast Python SDK
36-
37- ``` python
38- import os
39- from feast import FeatureStore, RepoConfig
40- from feast.registry import RegistryConfig
41- from feast_azure_provider.mssqlserver import MsSqlServerOfflineStoreConfig, MsSqlServerSource
42-
43- from feast import Entity, Feature, FeatureView, ValueType
44- from datetime import timedelta
45-
46- # update this to your location
47- registry_blob_url = " https://<ACCOUNT_NAME>.blob.core.windows.net/<CONTAINER>/<PATH>/registry.db"
48-
49- # update with your connection strings
50- sql_conn_string = " mssql+pyodbc://<USER_NAME>:<PASSWORD>@<SERVER_NAME>.database.windows.net:1433/<DB_NAME>?driver=ODBC+Driver+17+for+SQL+Server&autocommit=True"
51-
52- redis_conn_string = " <CACHE_NAME>.redis.cache.windows.net:6380,password=<PASSWORD>,ssl=True"
39+ ``` bash
40+ feast init -m my_feature_repo
41+ cd my_feature_repo
42+ ```
5343
54- reg_config = RegistryConfig(
55- registry_store_type = " feast_azure_provider.registry_store.AzBlobRegistryStore" ,
56- path = registry_blob_url,
57- )
44+ Rather than store credentials in your ` feature_store.yaml ` file, we recommend using environment variables:
5845
59- repo_cfg = RepoConfig(
60- registry = reg_config,
61- project = " production" ,
62- provider = " feast_azure_provider.azure_provider.AzureProvider" ,
63- offline_store = MsSqlServerOfflineStoreConfig(
64- connection_string = sql_conn_string
65- ),
66- )
46+ ``` bash
47+ export SQL_CONN=' mssql+pyodbc://<USER_NAME>:<PASSWORD>@<SERVER_NAME>.database.windows.net:1433/<DB_NAME>?driver=ODBC+Driver+17+for+SQL+Server&autocommit=True'
6748
68- store = FeatureStore( config = repo_cfg)
49+ export REDIS_CONN= ' <CACHE_NAME>.redis.cache.windows.net:6380,password=<PASSWORD>,ssl=True '
6950```
7051
71- #### b.) Using the Feast CLI
72-
73- Create your feature_store.yaml, which should contain the following:
52+ Update the ` feature_store.yaml ` :
7453
7554``` yaml
7655project : production
@@ -80,28 +59,85 @@ registry:
8059provider : feast_azure_provider.azure_provider.AzureProvider
8160offline_store :
8261 type : feast_azure_provider.mssqlserver.MsSqlServerOfflineStore
83- connection_string : mssql+pyodbc://<USER_NAME>:<PASSWORD>@<SERVER_NAME>.database.windows.net:1433/<DB_NAME>?driver=ODBC+Driver+17+for+SQL+Server&autocommit=True
62+ connection_string : ${SQL_CONN}
8463online_store :
8564 type : redis
86- connection_string : <CACHE_NAME>.redis.cache.windows.net:6380,password=<PASSWORD>,ssl=True
65+ connection_string : ${REDIS_CONN}
8766` ` `
8867
89- To apply features:
68+ ### 3. Register your feature definitions and set up your feature store
9069
9170` ` ` bash
9271feast apply
9372```
9473
95- To materialize features (adjust start and end times accordingly):
74+ ### 4. Build a training dataset
75+
76+ ``` python
77+ from feast import FeatureStore
78+ import pandas as pd
79+ from datetime import datetime
80+
81+ entity_df = pd.DataFrame.from_dict({
82+ " entity_id" : [], # list of entities e.g. customer_id
83+ " event_timestamp" : [
84+ datetime(2021 , 4 , 12 , 10 , 59 , 42 ),
85+ # list of datetimes
86+ ]
87+ })
88+
89+ store = FeatureStore(repo_path = " ." )
90+
91+ training_df = store.get_historical_features(
92+ entity_df = entity_df,
93+ features = [
94+ ' featureview1:feature1' ,
95+ ' featureview1:feature2' ,
96+ ' featureview2:feature1'
97+ ],
98+ ).to_df()
99+
100+ print (training_df.head())
101+
102+ # Train model
103+ model = ml.fit(training_df)
104+ ```
105+
106+ ### 5. Load feature values into your online store
96107
97108``` bash
98- feast materialize ' 2021-08-01T19:20:01' ' 2021-08-03T19:20:01'
109+ CURRENT_TIME=$( date -u +" %Y-%m-%dT%H:%M:%S" )
110+ feast materialize-incremental $CURRENT_TIME
111+ ```
112+
113+ ### 6. Read online features at low latency
114+
115+ ``` python
116+ from pprint import pprint
117+ from feast import FeatureStore
118+
119+ store = FeatureStore(repo_path = " ." )
120+
121+ feature_vector = store.get_online_features(
122+ features = [
123+ ' featureview1:feature1' ,
124+ ' featureview1:feature2' ,
125+ ' featureview2:feature1'
126+ ],
127+ entity_rows = [{" entity_id" : 1001 }] # for example: driver_id, customer_id
128+ ).to_dict()
129+
130+ pprint(feature_vector)
131+
132+ # Make prediction
133+ # model.predict(feature_vector)
99134```
100135
136+
101137## 🎓 Learn more
102138
103139- [ Feast website] ( http://feast.dev )
104- - [ Feast on Azure tutorial] ( ./docs/ tutorial/README.md )
140+ - [ Feast on Azure tutorial] ( ./tutorial/README.md )
105141
106142## Contributing
107143
0 commit comments