Reading Online Features for Inference using the Python SDK (for Testing)
Danger
Using the Python SDK to read online features is not recommended in production. It's much slower and is not designed for production workloads.
Authenticating with an API key
If you're using an EMR or Databricks notebook that has been configured to work with Tecton, you can skip this section as the API key is already configured.
Otherwise you'll need to set an API key to authenticate these requests.
First, use the CLI to create a key.
tecton api-key create --description "A sample key for the documentation".
Then set the API key in the SDK.
import tecton
tecton.conf.set("TECTON_API_KEY", "my-key-code")
Using the FeatureService.get_online_features()
method (for testing)
To fetch online features from a Feature Service containing both OnDemand Feature Views and materialized Feature Views, provide both join_keys
and request_data
as inputs. If your Feature Service only includes materialized Feature Views then you can omit the request_data
input, and vice-versa.
import tecton
my_fs = tecton.get_feature_service('fraud_detection_feature_service')
keys = {
"user_id": "C1000262126"
}
request_data = {
"amount" : 100
}
response = my_fs.get_online_features(join_keys=keys, request_data=request_data)
response.to_dict()